Skip to main content
Version: 22.3.0

Browser class

Browser represents a browser instance that is either:

Browser emits various events which are documented in the BrowserEvent enum.


export declare abstract class Browser extends EventEmitter<BrowserEvents>

Extends: EventEmitter<BrowserEvents>


The constructor for this class is marked as internal. Third-party code should not call the constructor directly or create subclasses that extend the Browser class.

Example 1

Using a Browser to create a Page:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
const page = await browser.newPage();
await page.goto('');
await browser.close();

Example 2

Disconnecting from and reconnecting to a Browser:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
// Store the endpoint to be able to reconnect to the browser.
const browserWSEndpoint = browser.wsEndpoint();
// Disconnect puppeteer from the browser.
await browser.disconnect();

// Use the endpoint to reestablish a connection
const browser2 = await puppeteer.connect({browserWSEndpoint});
// Close the browser.
await browser2.close();


connectedreadonlybooleanWhether Puppeteer is connected to this browser.
debugInforeadonlyDebugInfoGet debug information from Puppeteer.



Gets a list of open browser contexts.

In a newly-created browser, this will return a single instance of BrowserContext.

close()Closes this browser and all associated pages.

Creates a new browser context.

This won't share cookies/cache with other browser contexts.

defaultBrowserContext()Gets the default browser context.
disconnect()Disconnects Puppeteer from this browser, but leaves the process running.
isConnected()Whether Puppeteer is connected to this browser.
newPage()Creates a new page in the default browser context.

Gets a list of all open pages inside this Browser.

If there ar multiple browser contexts, this returns all pages in all browser contexts.

process()Gets the associated ChildProcess.
target()Gets the target associated with the default browser context).

Gets all active targets.

In case of multiple browser contexts, this returns all targets in all browser contexts.


Gets this browser's original user agent.

Pages can override the user agent with Page.setUserAgent().


Gets a string representing this browser's name and version.

For headless browser, this is similar to "HeadlessChrome/61.0.3153.0". For non-headless or new-headless, this is similar to "Chrome/61.0.3153.0". For Firefox, it is similar to "Firefox/116.0a1".

The format of Browser.version() might change with future releases of browsers.

waitForTarget(predicate, options)

Waits until a target matching the given predicate appears and returns it.

This will look all open browser contexts.


Gets the WebSocket URL to connect to this browser.

This is usually used with Puppeteer.connect().

You can find the debugger URL (webSocketDebuggerUrl) from http://HOST:PORT/json/version.

See browser endpoint for more information.