Set a Puppeteer page’s user agent with await page.setUserAgent({ userAgent: '…' }), and do it before navigating if the page should receive the override from its first request. This changes the page’s user-agent settings; use device emulation when you also need a known device profile and viewport.
Set a user agent on a Puppeteer page
Use the options-object form of Page.setUserAgent:
import puppeteer from 'puppeteer';
const browser = await puppeteer.launch();
try {
const page = await browser.newPage();
await page.setUserAgent({
userAgent: 'your user-agent string',
});
await page.goto('https://example.com');
// Continue with page work.
} finally {
await browser.close();
}
The call returns a promise, so await it before navigating or doing work that depends on the override. Replace the example string with one appropriate to the browser and scenario you intend to represent. The Puppeteer documentation does not specify a universally suitable current string, so avoid treating an arbitrary, hard-coded browser version as authoritative. See the Page.setUserAgent API documentation.
As an Amazon Associate I earn from qualifying purchases.
Optional metadata and platform
The options object can also include userAgentMetadata and platform. For example, add those fields only when you have the corresponding values for the browser scenario being represented:
Quick wins for a faster PC:
Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →await page.setUserAgent({
userAgent: 'your user-agent string',
userAgentMetadata: yourUserAgentMetadata,
platform: 'your platform',
});
The user-agent string alone should not be assumed to reproduce every characteristic of a real browser or device. Consult the installed Puppeteer version’s API documentation for the exact types and supported options.
#1 Best Overall
Choose between a page override and device emulation
| Approach | What it changes | When to use it |
|---|---|---|
page.setUserAgent() |
The page’s user-agent settings; the options form also supports metadata and platform. | When the user-agent override itself is the goal. |
page.emulate(device) |
A known device profile, including user agent and viewport. | When you want to emulate a device rather than change only the user-agent settings. |
Puppeteer describes page.emulate(device) as a shortcut for setting both the user agent and viewport. Set up emulation before navigation where possible: changing viewport dimensions can affect a page and may trigger a reload in some cases. Device definitions are available through Puppeteer’s KnownDevices list. See the page interaction guide for the emulation guidance.
Install Puppeteer or connect to a managed browser
The page-level user-agent call is the same idea whichever package you use; the difference is browser setup. The installation guide distinguishes the packages this way:
Rank #2
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
puppeteerdownloads a compatible Chrome version as part of installation.puppeteer-coredoes not download Chrome. Use it when connecting to a remote browser or managing browser binaries separately.
Choose the package that matches how Chrome is supplied in your environment, then apply the override to the page you will navigate.
Troubleshoot user-agent overrides
- The page still sends its old user agent: Make sure you call and await
page.setUserAgent()on the same page before navigation or other dependent work. - You need a mobile layout, not just a different user-agent string: A string override is not a complete device profile. Use
page.emulate(device)when the viewport and known device settings matter, and configure it before navigation where possible. - An older example fails against your installed package: API signatures can change. Check the documentation for the Puppeteer version you installed; the current API uses an options object, and the Next documentation marks a legacy positional signature as obsolete.
- Chrome does not launch with
puppeteer-core: That package does not download a browser. Supply or connect to a browser separately, or usepuppeteerif its bundled compatible Chrome setup fits your needs.
Or skip the browser setup
If your task is to capture a website rather than run a Puppeteer workflow, ScreenshotNeo offers a website screenshot API and MCP server. One GET request can return a screenshot or PDF; for example, the API call below requests a WebP shot:
Rank #3
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 and consent banners, newsletter popups, and chat widgets are handled before capture and can be disabled individually. Bot checks, blank pages, timeouts, failed loads, and cache hits cost nothing; response headers indicate the page verdict and whether the capture was billed. Its MCP server gives AI agents screenshot, page-info, and PDF-capture tools. The free plan includes 1,000 shots a month without a card; paid plans start at $5 for 3,000 shots.
Sign up for 1,000 free screenshots a month with no card.
Quick Recap
Best Value
Rank #4
- 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
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.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →




