October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsClean PCRecommendedOne scan can reveal what keeps slowing WindowsLook for cleanup and repair opportunities.Run ScanOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk4 min

Puppeteer Device: Configure a Browser Device

Use Puppeteer’s KnownDevices profiles or a custom Device object to configure page emulation before navigation; learn when to use viewport-only settings instead.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To emulate a named phone or tablet in Puppeteer, create a page, call page.emulate(KnownDevices['device name']), then navigate. For a custom layout, call page.setViewport() before navigation. These page-level settings emulate viewport and device metrics, and a named device profile also supplies a user agent; they are not a guarantee of complete physical-device behavior.

Emulate a named device

Puppeteer provides KnownDevices, a read-only catalog of named device profiles. Each Device has a userAgent string and viewport settings. Pass a profile to page.emulate() to apply both.

import puppeteer, {KnownDevices} from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  const device = KnownDevices['iPhone 17 Pro'];

  if (!device) {
    throw new Error('Device profile not found in this Puppeteer version');
  }

  await page.emulate(device); // Configure before navigation.
  await page.goto('https://example.com', {waitUntil: 'networkidle2'});
  await page.screenshot({path: 'iphone.png', fullPage: true});
} finally {
  await browser.close();
}

The named iPhone 17 Pro profile appears in the current KnownDevices reference. Device keys can vary with the installed Puppeteer release, so check the documentation matching your version if a profile is missing. Page.emulate() is documented as a shortcut for setting the page’s user agent and viewport.

Use a custom viewport or device profile

Set only the viewport

If you need a particular page size but do not need a paired device user agent, set the viewport directly. The values below define a 640-by-480 CSS-pixel viewport at device scale factor 1.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
import puppeteer from 'puppeteer';

const browser = await puppeteer.launch();
try {
  const page = await browser.newPage();
  await page.setViewport({
    width: 640,
    height: 480,
    deviceScaleFactor: 1,
  });
  await page.goto('https://example.com');
  await page.screenshot({path: 'custom-viewport.png'});
} finally {
  await browser.close();
}

Set a custom viewport and user agent together

When a custom setup needs both metrics and a specific user agent, pass a Device-shaped object to page.emulate(). Choose a user agent appropriate to your test; the example below uses a placeholder string rather than claiming to represent a particular handset.

const customDevice = {
  userAgent: 'YOUR_TEST_USER_AGENT',
  viewport: {
    width: 390,
    height: 844,
    deviceScaleFactor: 3,
    isMobile: true,
    hasTouch: true,
  },
};

await page.emulate(customDevice);
await page.goto('https://example.com');

The supported shape is documented by Puppeteer’s Device interface. Use a named preset when its supplied values fit the test; use a custom object when you need explicit control.

Configure emulation before navigation

Set the device or viewport before calling page.goto(). Emulation resizes the page, and Puppeteer cautions that many websites do not expect a phone-sized viewport to be applied midway through a session. Also, changing isMobile or hasTouch with setViewport() can reload a page in some cases, though it does not happen on every change. See the setViewport() reference.

  1. Create or select the page.
  2. Call page.emulate(device) for a named/custom device, or page.setViewport(options) for viewport-only work.
  3. Navigate only after the emulation settings are applied.

Page emulation is not browser screen configuration

page.emulate() changes one page’s device metrics and user agent. Puppeteer’s separate screen configuration controls the browser’s headless screen layout, which is useful for multi-screen scenarios rather than a substitute for mobile page emulation.

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

The screen configuration guide documents --screen-info, Browser.addScreen() and Browser.removeScreen() for headless use; adding or removing screens is headless-only. It states that the headless screen defaults to 800×600 when neither --screen-info nor --window-size is set. Browser.screens() is available in both headful and headless modes.

Troubleshoot common problems

  • Device key is undefined: The installed Puppeteer version may not include that profile. Check the matching KnownDevices documentation, then use an available key or define a custom device object.
  • The page reloads or layout changes after setup: Apply emulation before navigation. If you change isMobile or hasTouch on an existing page, a reload is possible; account for it in the test.
  • The site still does not behave like a physical phone: The documented API covers user-agent and viewport/device metrics, not a guarantee of complete handset fidelity. Test the specific browser behavior your application depends on.
  • A custom viewport changes layout but not server responses: A viewport-only call does not set a device user agent. Use a custom Device object with both userAgent and viewport if both are required.

Or skip the browser setup

For a screenshot without maintaining Puppeteer code, ScreenshotNeo provides a website screenshot API and MCP server. One GET request returns an image or PDF. Its capture flow accepts cookie/consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups and chat widgets before capture; each cleanup step can be turned off. Bot checks/CAPTCHAs, blank pages, timeouts, failed loads and cache hits are not billed, and responses identify the page verdict and billing status in headers. Its MCP server offers take_screenshot, get_page_info and capture_pdf for AI agents.

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

See the ScreenshotNeo API documentation. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000. Sign up for ScreenshotNeo free.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Frequently Asked Questions

Does Puppeteer device emulation guarantee that a page behaves exactly like a real phone?

No. The documented emulation covers the user agent and viewport/device metrics, not complete physical-device fidelity.

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

Can I configure a device after the page has loaded?

You can change settings, but resizing can affect the page and changing mobile or touch settings can cause a reload in some cases. Applying them before navigation is the safer sequence.

Best Value
The SQL Programming Language: .
  • Used Book in Good Condition

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 *

Free tools Windows power users keep installed

One-click scans. No signup required.

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
Windows Errors? Fix Them Before They SpreadFree repair scan
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.