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

Use page.setViewport() to set a Puppeteer page’s width and height in CSS pixels. Set it before page.goto() so the site sees the intended viewport on its initial load. Add isMobile and hasTouch only when your test needs those mobile behaviors.

Set a mobile-sized viewport

This example sets a 390 × 844 CSS-pixel viewport and enables mobile and touch emulation:

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  await page.setViewport({
    width: 390,
    height: 844,
    deviceScaleFactor: 1,
    isMobile: true,
    hasTouch: true,
  });

  await page.goto('https://example.com');
  // Run assertions or capture a screenshot here.

  await browser.close();
})();

The dimensions are an illustrative test choice, not a Puppeteer standard or a universal phone size. Puppeteer’s width and height values are CSS pixels. The device scale factor is a separate setting; it controls the emulated device scale factor, rather than changing the CSS-pixel dimensions.

Choose the right viewport setup

Test a responsive breakpoint with manual dimensions

For a layout test, set the width and height to the dimensions you want to check. A responsive site’s CSS media queries generally respond to viewport width, so use a value near the breakpoint you are testing. Include isMobile or hasTouch only if the behavior being tested depends on mobile viewport handling or touch-event support. A narrow viewport by itself may be enough to test a layout breakpoint.

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.
#1 Best Overall
Sale
Motorola Moto g - 2026 | Unlocked | Made for US 4/128GB | 50MP Camera | Pantone Slipstream, Cellular_Phone
  • Universal unlocked. Compatible with all major U.S. carriers, including Verizon, AT&T, T-Mobile and other prepaid carriers.
  • Super-bright, super-smooth 6.7" display. See your screen clearly even outdoors in sunlight, and enjoy seamless views with a fast-refreshing 120Hz display.*
  • AI-powered camera system. Take stunning photos in any light with the 50MP camera**, look your best with a 32MP selfie cam*****, and capture extreme close-ups.
  • Superfast 5G performance. Unleash your entertainment at 5G speed*** with the MediaTek Dimensity 6300 chipset and up to 12GB of RAM with RAM Boost****.
  • Long-lasting battery + TurboPower charging. Power through day after day with a 5200mAh battery, then get hours of power in just minutes.****

Emulate a named device profile

When the test calls for a particular device configuration rather than an arbitrary viewport, use page.emulate() with a profile from KnownDevices. Puppeteer documents KnownDevices['iPhone 17 Pro'] as an example:

const puppeteer = require('puppeteer');
const { KnownDevices } = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();

  await page.emulate(KnownDevices['iPhone 17 Pro']);
  await page.goto('https://example.com');

  // Run assertions or capture a screenshot here.
  await browser.close();
})();

page.emulate() applies a profile’s device metrics and user agent. Puppeteer documents it as a shortcut for setting the user agent and viewport together. A named profile is useful when those settings should be coordinated; manual dimensions are more direct when the test is specifically about a chosen layout size.

Rank #2
Sale
Samsung Galaxy A17 5G Smart Phone 128GB US 1 Yr Manufacturer Warranty Black
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Compare the two approaches

Approach What it sets Best suited to
page.setViewport() The width, height, and any viewport options you specify. Testing a chosen breakpoint or custom viewport size.
page.emulate() A predefined device profile’s metrics and user agent. Testing against a named device configuration.

Set it before navigation

Apply the viewport or device profile before calling page.goto(). Puppeteer’s official documentation recommends setting the viewport before navigating because sites may not expect phone-sized viewport changes after the page has loaded. Setting properties such as isMobile or hasTouch can reload the page in some cases, so configuring them up front avoids an unnecessary navigation change during the test.

Each page can have its own viewport. page.viewport() reports the viewport settings last set on that page, or the default viewport from the browser connection options. It reports the configured settings; it does not inspect the browser’s actual rendered viewport.

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.
Rank #3
Samsung Galaxy A16 5G 128GB Cell Phone, Unlocked Android Smartphone, Large AMOLED Display, Durable Design, Super Fast Charging, Expandable Storage, US Version, 2025, Blue Black (Renewed)
  • Charger NOT Included, 6.7" Super AMOLED FHD+, 90Hz Refresh Rate, 385 ppi, 800 nits (HBM), 1080x2340px, 5000mAh Battery
  • 128GB, 4GB RAM, microSDXC, Exynos 1330 (5nm), Octa-Core, Mali-G68 MP2 or Mali-G57 MC2 GPU
  • Rear Camera: 50MP, f/1.8 (wide) + 5MP, f/2.2 (ultrawide) + 2MP, f/2.4 (macro), LED flash, panorama, HDR; Front Camera: 13MP, f/2.0, Android 14, up to 6 major Android upgrades, One UI 6.1
  • 3G: HSDPA 850/900/1700(AWS)/1900/2100; 4G LTE: 1/2/3/4/5/7/12/13/14/20/25/26/28/29/30/38/39/40/41/48/66/71, 5G: 2/5/25/41/66/71/77/78 SA/NSA/Sub6/mmWave - Nano-SIM + eSIM
  • US Model – Global Connectivity – Compatible with Most GSM Carriers like T-Mobile, AT&T, MetroPCS, etc. Will Also work with CDMA Carriers Such as Verizon, Straight Talk.

Viewport options to know

  • width and height: dimensions in CSS pixels.
  • deviceScaleFactor: the emulated device scale factor, useful when the test needs a particular pixel density.
  • isMobile: controls whether the page’s meta viewport tag is taken into account during emulation.
  • hasTouch: specifies whether the emulated viewport supports touch events.
  • isLandscape: sets the landscape orientation option when your test needs it.

Set only the options that matter to the behavior under test. Viewport sizing does not by itself reproduce every physical-device condition; for example, this setup describes the emulated dimensions and options rather than proving how a real handset will behave.

Restore the default viewport

To return a page to its default viewport, call:

await page.setViewport(null);

Troubleshoot viewport tests

The page still looks like a desktop layout

Check that you set the viewport before navigation and that the width is below the responsive breakpoint you intend to test. If the site’s behavior depends on its meta viewport tag, set isMobile: true; a small width alone does not enable that emulation behavior.

Rank #4
Sale
Samsung Galaxy A17 5G Smart Phone 128GB, US 1 Yr Manufacturer Warranty Blue
  • YOUR CONTENT, SUPER SMOOTH: The ultra-clear 6.7" FHD+ Super AMOLED display of Galaxy A17 5G helps bring your content to life, whether you're scrolling through recipes or video chatting with loved ones.¹
  • LIVE FAST. CHARGE FASTER: Focus more on the moment and less on your battery percentage with Galaxy A17 5G. Super Fast Charging powers up your battery so you can get back to life sooner.²
  • MEMORIES MADE PICTURE PERFECT: Capture every angle in stunning clarity, from wide family photos to close-ups of friends, with the triple-lens camera on Galaxy A17 5G.
  • NEED MORE STORAGE? WE HAVE YOU COVERED: With an improved 2TB of expandable storage, Galaxy A17 5G makes it easy to keep cherished photos, videos and important files readily accessible whenever you need them.³
  • BUILT TO LAST: With an improved IP54 rating, Galaxy A17 5G is even more durable than before.⁴ It’s built to resist splashes and dust and comes with a stronger yet slimmer Gorilla Glass Victus front and Glass Fiber Reinforced Polymer back.

Touch interactions are not available

Set hasTouch: true when the test needs touch-event support. A mobile-sized viewport does not automatically mean the viewport supports touch events.

The page reloads after changing settings

Some changes, including setting isMobile or hasTouch, can reload the page. Configure these values before page.goto() rather than changing them after the site has loaded.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Tracfone Motorola Moto G 2025, 64GB, Saphire Blue (Locked to
  • Carrier: This phone is locked to Tracfone, which means this device can only be used on the Tracfone wireless network. Tracfone plan required, activating is easy, just 3 steps.
  • DISPLAY: Immersive viewing on a 6.7-inch super-bright 120Hz display with powerful stereo speakers and Bass Boost for cinematic entertainment.
  • CAMERA SYSTEM: Advanced 50MP Quad Pixel camera captures sharp, detailed photos and videos in any lighting condition
  • PERFORMANCE: Lightning-fast 5G connectivity paired with a powerful processor and RAM Boost for smooth multitasking.
  • BATTERY LIFE: Long-lasting 5000mAh battery with TurboPower charging technology delivers hours of power in minutes.

The reported viewport does not match what you expect

page.viewport() returns Puppeteer’s configured viewport settings, not a measurement of the rendered page. Check the values passed to setViewport() or the selected device profile, and make sure you are querying the page you configured.

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 to capture a website rather than run Puppeteer-specific viewport or touch tests, ScreenshotNeo is a screenshot API and MCP server for developers. It supports 12 device presets and custom viewports; the Puppeteer flags and page-level behavior above remain Puppeteer-specific.

One GET request can return a screenshot. For example, this cURL request saves a WebP capture of Stripe; see the ScreenshotNeo API documentation for configuration details:

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie and consent banners, newsletter popups, and chat widgets are removed before capture; each cleanup step can be turned off.
  • Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers report the page verdict and billing status.
  • 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 for ScreenshotNeo’s free plan to get 1,000 screenshots a month with no card.

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

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.