Recommended Free Tools
Use browser.createBrowserContext() to create a separate Puppeteer session, open its pages with context.newPage(), and call context.close() when the session is finished. Puppeteer documents that contexts do not share cookies or cache with other contexts; its BrowserContext reference also describes isolation for storage such as cookies and localStorage. That is storage isolation—not a promise of complete browser-resource or security isolation.
What a browser context isolates
A browser context is a user context within a browser. A newly launched browser has at least one default context; create additional contexts when tasks need separate documented storage state. Puppeteer says cookies and localStorage are isolated between contexts, and the creation method specifically says contexts do not share cookies or cache. See the BrowserContext API reference and createBrowserContext() reference (API documentation identified as version 25.12.0).
As an Amazon Associate I earn from qualifying purchases.
Pages created in the same context are part of that session. A popup opened by one of those pages, such as through window.open(), also belongs to the parent page’s context. Puppeteer’s browser management guide recommends BrowserContexts when automation tasks need isolation.
The documentation does not establish that contexts isolate every browser-level resource or provide a security boundary for untrusted tenants. Treat them as a way to separate the documented session storage and cache behavior, not as a substitute for process- or system-level security controls.
#1 Best Overall
Create a context, use it, and close it
This ES module example creates one session, navigates a page in it, and ensures the context and browser are closed even if navigation or other work throws an error. It uses documented API calls composed into a cleanup-safe workflow.
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const context = await browser.createBrowserContext();
try {
const page = await context.newPage();
await page.goto('https://example.com');
// Work with this session's pages and context-scoped state.
} finally {
await context.close();
}
} finally {
await browser.close();
}
- Launch the browser.
puppeteer.launch()returns the browser that owns the contexts. - Create a non-default context. Call
browser.createBrowserContext(). In Chrome, Puppeteer documents that non-default contexts are incognito. The default context may also be incognito if Chrome was launched with--incognito. - Create pages through the context. Call
context.newPage(), rather thanbrowser.newPage(), so the page belongs to the session you intend to isolate. - Do the session’s work. Navigate and interact with the page. Additional pages made with
context.newPage()share that context’s session state; popups opened by a page stay in its context. - End the session. Call
context.close()to close that context and all its associated pages. Then callbrowser.close()when the whole browser should shut down.
Manage cookies at the context level
Use the BrowserContext cookie methods when you need to inspect, set, or delete cookies for a session. The context API includes cookies(), setCookie(), and cookie deletion methods. Page-level cookie methods are marked deprecated in the Page API reference, which directs users to browser- or context-level alternatives.
Rank #2
Keep cookie operations tied to the same context as the pages whose session state you intend to manage. A context’s cookies are not shared with other contexts. Consult the current BrowserContext API reference for the exact method signatures and options supported by the Puppeteer version installed in your project.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Choose between a shared context and separate sessions
| Need | Approach | Documented effect |
|---|---|---|
| Several pages should work within one session | Create them with the same context.newPage() |
They belong to the same context; popups remain in their parent page’s context. |
| Separate cookie, localStorage, or cache state across tasks | Create a distinct context for each session with browser.createBrowserContext() |
Contexts do not share cookies or cache; storage such as cookies and localStorage is isolated. |
| Discard every page in one session together | Call context.close() |
The context and its associated pages close; the browser itself remains open. |
These APIs establish the behavior above, but Puppeteer’s cited documentation does not give performance benchmarks for creating a context per task versus reusing pages. Choose based on whether tasks need separate session state and independent teardown; measure your own workload if context creation overhead matters.
Troubleshooting context workflows
- A page unexpectedly shares session state: Check how it was created. Use
context.newPage()on the intended context; pages created from the browser’s default context are not automatically moved into another context. - A popup appears in the wrong session: A popup opened by a page belongs to that parent page’s context. Open it from a page already created in the intended context.
- Other contexts cannot see a cookie: This is expected isolation. Set or inspect the cookie through the context associated with the page that needs it.
- Closing a context closes pages you still need:
context.close()closes all pages associated with it. Keep pages that must remain available in a different context. - You cannot close the default context: Puppeteer documents that the default browser context cannot be closed. Close a non-default context to end an isolated session, or close the browser to end the browser process and its contexts.
Or skip the browser setup:
If your goal is simply to capture a website rather than automate an isolated browser session, ScreenshotNeo provides a screenshot API and MCP server. One GET request can return an image or PDF; its clean-shot options can accept consent banners and remove known consent platforms, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are not billed, and its MCP server lets AI agents take screenshots.
For example, this cURL request saves a WebP screenshot:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. It includes 1,000 screenshots per month free with no card; paid plans start at $5 for 3,000. Sign up for the free plan.
Rank #4
Frequently Asked Questions
Can I use a BrowserContext as a security boundary between untrusted users?
No such guarantee is established by the cited Puppeteer documentation. It documents separation of cookies, localStorage, and cache, not complete resource or process isolation.
Does closing a BrowserContext shut down Puppeteer?
No. It closes that context and its associated pages. Close the browser separately with browser.close() when the browser should stop.
Quick Recap
Best Value
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.




