ScreenshotNeo

BlogHow-to

Puppeteer lastLaunchedBrowser(): Get the Last Launched Browser

Use Puppeteer's `lastLaunchedBrowser` property to identify the browser type used by the most recent launch, and understand how it differs from the default.

By the ScreenshotNeo team4 October 20266 min read

In Puppeteer’s Node API, read puppeteer.lastLaunchedBrowser. It is a property (a getter), not a method: it identifies the name or type of browser that was last launched. It does not return the browser instance. Its declared type is SupportedBrowser. See the PuppeteerNode API reference.

This property answers a different question from puppeteer.defaultBrowser: lastLaunchedBrowser describes the last launch, while defaultBrowser identifies what Puppeteer will launch by default. The legacy product getter is deprecated; use the dedicated properties instead. See the PuppeteerNode API and PuppeteerNode type declaration.

Read the property in Node.js

Install Puppeteer if it is not already in your project:

npm install puppeteer

Then launch a browser and inspect the property:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  try {
    console.log('Last launched browser:', puppeteer.lastLaunchedBrowser);
    console.log('Default browser:', puppeteer.defaultBrowser);
  } finally {
    await browser.close();
  }
})();

With ECMAScript modules, use the same property without parentheses:

import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  console.log(puppeteer.lastLaunchedBrowser);
} finally {
  await browser.close();
}

Run the file with Node.js. The launch resolves to a Browser instance, which is why the example stores it separately in browser. The property is on the Puppeteer Node API object, puppeteer.

Value What it tells you Use it for
puppeteer.lastLaunchedBrowser The name/type of the browser last launched, according to the API reference. Inspecting the most recent launch selection.
puppeteer.defaultBrowser The browser Puppeteer will use by default. Inspecting the default selection before or apart from a launch.
puppeteer.product Legacy getter, deprecated because it does not account for multiple browser types. Do not use in new code; migrate to the dedicated properties.
The value returned by await puppeteer.launch() A Browser instance. Opening pages, controlling the running browser, and closing it.

These values are not interchangeable. In particular, do not call puppeteer.lastLaunchedBrowser(): the API exposes a property, not a function. Do not expect it to provide methods such as newPage(); those belong to the Browser instance returned by launch().

Choose a browser when launching

puppeteer.launch() starts a browser and resolves to a Promise<Browser>. It accepts optional launch options. For example, specify a browser channel when you want to launch an installed Chrome channel:

const browser = await puppeteer.launch({ channel: 'chrome' });
try {
  console.log('Last launched browser:', puppeteer.lastLaunchedBrowser);
} finally {
  await browser.close();
}

The exact supported browser choices and options depend on the Puppeteer package and version. Check the official launch reference and the API reference for your installed version. With puppeteer-core, provide an executable path or a browser channel; it does not provide the bundled browser used by the full puppeteer package.

Keep the browser instance for browser operations:

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

Launch versus connect

Puppeteer supports both launching a new browser and connecting to one that is already running. The meaning documented for lastLaunchedBrowser is about the last browser launched. The reviewed reference does not specify what this property reports before the first launch, how it changes after successive launches, or what it reports after connecting to an externally started browser. Do not rely on those details without checking the exact Puppeteer version and behavior your application uses.

For a browser started by Puppeteer, browser.close() shuts it down. For a browser you connected to, browser.disconnect() closes Puppeteer’s connection while leaving the browser and its pages running. See the browser management guide.

Version-aware usage and edge cases

  • Check the installed package. The property belongs to the Node API. Confirm that the package and version in use expose it in their API reference and type declarations.
  • Read it from the Puppeteer object. Do not look for it on a page or treat it as the browser instance.
  • Do not infer undocumented state. The reference does not define the initial value, successive-launch update rules, or connected-browser behavior.
  • Prefer specific properties to product. The deprecated getter does not account for multiple browser types.
  • Handle launch errors separately. If launch() rejects, execution will not reach the subsequent property log unless the error is caught.
  • Close resources in cleanup. Use try/finally so an error during page work does not leave a launched browser running.

Troubleshooting

Symptom Likely cause Fix
puppeteer.lastLaunchedBrowser is not a function The property was called with parentheses. Read puppeteer.lastLaunchedBrowser without parentheses.
The value is missing or differs from expectation The installed version, launch sequence, or connection path may not match the assumptions in the code; some lifecycle details are not specified by the reviewed reference. Check the installed version’s API docs and type declarations. Verify the code actually called launch(), and avoid depending on undocumented initial or connection state.
puppeteer.product is deprecated Code still uses the legacy getter. Use defaultBrowser for the default selection or lastLaunchedBrowser for the last launch.
puppeteer-core cannot find a browser The core package requires an executable path or channel. Pass a valid executablePath or channel in launch options, as supported by your installed version.
The browser process remains open The launched browser was not closed after work completed. Call await browser.close() in a finally block. If you connected to an existing process and want it to continue running, use browser.disconnect().

Performance, reliability, and cost

Reading this getter is a local property access; the meaningful runtime and resource costs come from launching and operating a browser. Browser launches consume time and system resources, so reuse a browser where your application’s lifecycle allows it, and close launched instances when finished. The API reference does not provide a benchmark or guarantee about getter behavior beyond its description and type.

For reliable automation, make browser lifecycle explicit: await the launch, retain its returned instance, and close or disconnect it intentionally. Treat launch failures as launch failures rather than assuming the property alone proves that a usable browser process is available.

Or skip the browser setup

If your goal is to capture a webpage image rather than manage a local Puppeteer browser, ScreenshotNeo is a website screenshot API and MCP server. It accepts one GET request and returns a PNG, JPEG, WebP, or PDF. Its API documentation has the request options.

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

r = requests.get(
    "https://api.screenshotneo.com/v1/shot",
    params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"},
    timeout=90,
)
open("shot.webp", "wb").write(r.content)
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
if (!res.ok) throw new Error(`Screenshot request failed: ${res.status}`);
await Bun.write('shot.webp', res);
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off.
  • Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed. Responses include X-Page-Verdict and X-Billed headers.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up free for 1,000 screenshots a month, with no card required.

FAQ

Does lastLaunchedBrowser return a browser object?

No. The API describes a browser name or type and declares the property as SupportedBrowser. Keep the object returned by await puppeteer.launch() for browser operations.

Is lastLaunchedBrowser() a function?

No. Despite the parentheses in some search phrasing, the API is a getter property. Use puppeteer.lastLaunchedBrowser.

Can I use it to determine the next browser Puppeteer will launch?

Use puppeteer.defaultBrowser to inspect the default selection. The last launched browser and default browser answer different questions.

What does it return before a launch or after connect()?

The reviewed reference does not specify those cases. Check the documentation and type declarations for the exact version you run, and avoid treating an undocumented value as a stable contract.