October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk2 min

How to Get the Browser from a Puppeteer BrowserContext

Call context.browser() to synchronously retrieve the Browser associated with a Puppeteer BrowserContext. From a Page, use page.browserContext().browser().
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Call context.browser(). It synchronously returns the Browser instance associated with that Puppeteer BrowserContext; no await is needed. See the Puppeteer API reference.

Get the browser from a BrowserContext

Use the context’s browser() method:

const browser = context.browser();

The method returns a Browser, not a promise. Calling it retrieves the browser already associated with the context; it does not launch another browser. The signature and return type are documented in the BrowserContext.browser() reference.

As an Amazon Associate I earn from qualifying purchases.

Runnable example

This ES module example launches Puppeteer, creates a context and page, then gets the same browser instance from the context:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const context = await browser.createBrowserContext();
const page = await context.newPage();

const sameBrowser = context.browser();
console.log(sameBrowser === browser); // expected to be true

await context.close();
await browser.close();

The browser launch and context/page creation are asynchronous, so they use await. The accessor context.browser() is synchronous. The equality check follows from the documented association between the context and its browser; it is not a separate Puppeteer guarantee about every possible setup.

Starting from a Page

If you have a Puppeteer Page rather than its context, get the context first, then the browser:

const browser = page.browserContext().browser();

Page.browserContext() returns the context to which the page belongs; BrowserContext.browser() returns that context’s browser. Both accessors are synchronous. See the Page.browserContext() reference and the BrowserContext.browser() reference.

Rank #2
Sale
HTML and CSS: Design and Build Websites
  • HTML CSS Design and Build Web Sites
  • Comes with secure packaging
  • It can be a gift option

How Browser, BrowserContext, and Page relate

  • Browser represents a browser instance launched with Puppeteer or connected through Puppeteer.connect().
  • BrowserContext represents a user context within that browser. Contexts isolate storage such as cookies and local storage, and can be created with browser.createBrowserContext().
  • Page belongs to a context. A page can reach its context with page.browserContext().

Consequently, retrieving a browser from a context gives you the associated existing browser, not a new instance. See the BrowserContext documentation and Browser documentation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Common mistakes and fixes

  • Adding unnecessary await: await context.browser() is unnecessary because the method returns Browser directly.
  • Using the context-listing method: browser.browserContexts() lists contexts; it is not the accessor for the browser from a context. Call context.browser().
  • Starting from a page: Call page.browserContext().browser(), rather than looking for the browser directly on the page.
  • Closing the wrong object: context.close() closes that context and its associated pages. The default browser context cannot be closed; consult the BrowserContext lifecycle documentation.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Or skip the browser setup

If your goal is simply to capture a website rather than control Puppeteer directly, ScreenshotNeo returns a screenshot or PDF from one GET request. For example, this cURL request saves a WebP screenshot:

Rank #4
Sale
Web Design with HTML, CSS, JavaScript and jQuery Set
  • Brand: Wiley
  • Set of 2 Volumes
  • A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

See the ScreenshotNeo API documentation for request options. Cookie banners, popups and chat widgets are removed before capture; bot checks, blank pages and failed loads are never billed. Its MCP server lets AI agents take screenshots. The free plan includes 1,000 screenshots a month with no card, and paid plans start at $5 for 3,000. Sign up for free.

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.