DriversRecommendedOutdated drivers can make a good PC feel brokenScan driver issues before chasing fixes manually.Scan NowOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
Skip to content
World desk3 min

Open a New Page with Puppeteer

Use await browser.newPage() to create a Puppeteer page. Learn when to use a separate browser context and how to connect to an existing browser safely.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To open a new page with Puppeteer, launch or connect to a browser, then await browser.newPage(). It returns a Page object you can use to navigate and interact with that page.

Open a page after launching Puppeteer

This complete ES module example creates a browser, opens a page in its default browser context, visits a URL, and closes the browser it launched:

As an Amazon Associate I earn from qualifying purchases.

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.goto('https://example.com');
  console.log(await page.title());
} finally {
  await browser.close();
}

The launch → page creation → navigation → cleanup sequence follows Puppeteer’s getting-started guide. browser.newPage() is asynchronous and resolves to a Page object. A browser can have multiple Page instances, each controlling a tab-like page.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Choose the right browser context

Call Where the page belongs Use it when
browser.newPage() The browser’s default context You want the straightforward page-creation path.
context.newPage() A separately created browser context You want browser state such as cookies and local storage isolated from other contexts, or want to close the context’s pages together.

The context controls the state-isolation boundary. Create one with browser.createBrowserContext(), then create its page with context.newPage(), as shown in the official browser-management guide.

const context = await browser.createBrowserContext();
try {
  const page = await context.newPage();
  await page.goto('https://example.com');
} finally {
  await context.close();
}

Closing the context closes its pages. If you also launched the browser for this script, close the browser when the work is complete.

Open a page in a browser that is already running

When another process owns the browser lifecycle, connect to it rather than launching a second browser. The connection requires the browser WebSocket endpoint or another supported connection option for your setup.

import puppeteer from 'puppeteer';

const browser = await puppeteer.connect({
  browserWSEndpoint: process.env.BROWSER_WS_ENDPOINT,
});

try {
  const page = await browser.newPage();
  await page.goto('https://example.com');
} finally {
  await browser.disconnect();
}

Set BROWSER_WS_ENDPOINT to the endpoint provided by the browser you are connecting to. Use browser.disconnect() here: it detaches Puppeteer without shutting down the externally launched browser or closing its pages. By contrast, browser.close() closes the browser and is appropriate when your script owns that lifecycle.

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

Common problems and fixes

  • browser.newPage is not a function: Make sure you are calling it on the Browser object returned by puppeteer.launch() or puppeteer.connect(), not on the Page object returned by newPage().
  • The call is made before the browser is ready: Await puppeteer.launch() or puppeteer.connect() before calling browser.newPage(); await browser.newPage() itself before using the returned page.
  • The new page shares browser state you wanted isolated: browser.newPage() uses the default context. Create a separate context with browser.createBrowserContext() and call context.newPage().
  • The browser unexpectedly shuts down: If another process launched it, use browser.disconnect() for cleanup instead of browser.close().
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 a website screenshot rather than browser automation, ScreenshotNeo returns a screenshot or PDF from one GET request. See the API documentation for options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo accepts cookie and consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing, with response headers indicating the page verdict and billing status. Its MCP server offers screenshot, page-info, and PDF tools for AI agents. The free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000 shots.

Sign up for ScreenshotNeo’s free plan.

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
PC Slower Than It Used to Be?Free scan - under a minute
Outdated Drivers Are Slowing You DownFree scan - exact matches

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.