To open a new page with Puppeteer, launch or connect to a browser, then call await browser.newPage(). It returns a Page object you can use to navigate and interact with that page.
Open a page after launching Puppeteer
For a script that manages its own browser, create the browser first, open a page, use it, and close the browser when finished. This ES module example follows Puppeteer’s documented launch, page creation, navigation, and cleanup sequence: Getting started.
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();
}
browser.newPage() is asynchronous, so use await. It creates the page in the browser’s default context and resolves to a Puppeteer Page object, not a URL or browser instance. See the Browser.newPage() API reference and the Page class reference.
Choose the right browser context
| Call | Where the page belongs | Use it when |
|---|---|---|
browser.newPage() |
The default browser context | You want the straightforward page-creation path and do not need a separate context for this task. |
context.newPage() |
A separately created browser context | You want browser state, including cookies and local storage, isolated from other contexts or want to manage the pages together. |
Puppeteer’s browser management guide demonstrates creating a context and opening a page inside it:
#1 Best Overall
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const context = await browser.createBrowserContext();
const page = await context.newPage();
await page.goto('https://example.com');
console.log(await page.title());
await context.close();
} finally {
await browser.close();
}
Closing the context closes the pages belonging to it. Use contexts when you need that isolation or grouped lifecycle; the documented sources do not establish a performance advantage for either creation method.
Open a page in a browser that is already running
If another process or service owns the browser, connect to it instead of launching another one. After connecting, create a page through the returned Browser object:
Rank #2
import puppeteer from 'puppeteer';
const browser = await puppeteer.connect({
browserWSEndpoint: process.env.PUPPETEER_WS_ENDPOINT,
});
try {
const page = await browser.newPage();
await page.goto('https://example.com');
console.log(await page.title());
} finally {
await browser.disconnect();
}
Set PUPPETEER_WS_ENDPOINT to the WebSocket endpoint for the browser you intend to control. When connected to an externally launched browser, browser.disconnect() detaches Puppeteer without shutting down that browser or closing its pages. Do not substitute browser.close() when the external process should remain running. The connect and cleanup behavior is documented in the browser management guide.
Common problems and fixes
- The page variable is not a Page: Make sure you call
await browser.newPage()and assign its result. The method resolves asynchronously. - Navigation fails after page creation: Creating a page does not navigate it. Call
await page.goto(url)separately and check that the URL is reachable from the environment running Puppeteer. - The browser closes unexpectedly: Check that cleanup is not running before page operations finish. In scripts that launch the browser, close it after the work is complete.
- An externally managed browser shuts down: Use
browser.disconnect()to detach.browser.close()closes the browser Puppeteer controls. - Pages share browser state unexpectedly:
browser.newPage()uses the default context. Create a separate browser context and usecontext.newPage()for context-level isolation.
Or skip the browser setup
If your goal is a website screenshot rather than browser interaction, ScreenshotNeo can return an image or PDF from one GET request. Its documentation describes the API.
Quick Recap
Best Value
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; those steps can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response identifies the page verdict and billing status. It also provides an MCP server for AI agents, including Claude, Cursor, and other MCP clients. The Free plan includes 1,000 screenshots a month without a card; paid plans start at $5 for 3,000 shots. Learn more at ScreenshotNeo, or sign up for the 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.

