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

Render the React app in a browser, wait until the content you need is ready, then save a screenshot as PNG. With Playwright, page.screenshot() captures the visible viewport by default; set fullPage: true for the full document or locate an element to capture one component. JSX alone is not an image: the browser must render it first.

Capture a React page with Playwright

Install Playwright in the project, start the app, and use a browser page to capture its rendered output. The example below assumes the app is already running at http://localhost:3000; replace that URL with the route you want to capture.

  1. Install Playwright: npm install -D playwright

  2. Install its Chromium browser if needed: npx playwright install chromium

  3. Save this as screenshot.mjs and run it with node screenshot.mjs.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    #1 Best Overall
    Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
    • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
    • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
    • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
    • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
    • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.
import { chromium } from 'playwright';

const browser = await chromium.launch({ headless: true });
try {
  const page = await browser.newPage({ viewport: { width: 1440, height: 900 } });
  await page.goto('http://localhost:3000', { waitUntil: 'networkidle' });
  await page.screenshot({ path: 'react-page.png', type: 'png' });
} finally {
  await browser.close();
}

PNG is Playwright’s default screenshot format, but specifying type: 'png' makes the intent explicit. Its Page API documentation lists the screenshot options. The Puppeteer screenshot guide documents the same general flow: launch a browser, open a page, navigate, and take a screenshot.

Choose what to capture

Visible viewport

The default screenshot shows only the currently visible browser area, using the viewport dimensions configured for the page. In the example, that is 1440 by 900 CSS pixels.

Full scrollable page

Set fullPage: true to capture the full document vertically rather than just the viewport:

await page.screenshot({ path: 'react-page-full.png', fullPage: true });

One component or region

Locate the element and ask Playwright to screenshot it. This is usually simpler and more robust than calculating a clip rectangle by hand:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
const card = page.locator('[data-testid="product-card"]');
await card.screenshot({ path: 'product-card.png' });

Use a selector that identifies the intended component uniquely. Playwright also supports clipping to a specified region; consult its screenshot API for the current option names and behavior.

Wait for the React content you actually need

No single navigation event guarantees that every React page has finished rendering. A route can load its shell before application data, images, or web fonts arrive. Choose a readiness signal specific to your app, such as a selector that appears once the content is usable:

await page.goto('http://localhost:3000/report');
await page.getByRole('heading', { name: 'Monthly report' }).waitFor();
await page.locator('[data-testid="report-chart"]').waitFor();
await page.screenshot({ path: 'report.png', fullPage: true });

When the screenshot depends on API data, wait for the rendered result or an explicit application-ready marker—not merely for the URL to load. For lazy-loaded images farther down a long page, scroll through the relevant content before taking a full-page screenshot so the app has a chance to load them. The exact readiness checks depend on how the page fetches and renders content.

Control output dimensions and visual state

CSS pixels versus device pixels

Playwright’s screenshot scale option controls the output pixel density. Use css for one output pixel per CSS pixel; use device when you want the device-scale factor reflected in the image’s pixel dimensions. The latter can create a larger image in a high-DPI context. See the API reference for the installed version’s supported values.

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.
Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

Deterministic or user-like appearance

For a faithful view, leave page animations and transient interface elements as users see them. For a controlled artifact or visual check, Playwright provides screenshot options for animation handling, masks, transparent backgrounds, and screenshot-specific styles. These can change what appears in the image; choose them deliberately rather than treating a modified screenshot as an exact view of the live page.

Other browser automation option: Puppeteer

If the project already uses Puppeteer, its screenshot API can capture the browser page or a selected element. The basic pattern is to launch Chromium, create a page, navigate to the React route, and call page.screenshot(). The official guide includes examples; check the documentation for the Puppeteer version installed in your project. Neither the official Playwright nor Puppeteer material establishes a universal speed winner, so an existing project stack and required screenshot controls are sensible decision factors.

Keep visual screenshots repeatable

For visual regression checks, keep the rendering environment consistent. Playwright notes that screenshots can vary with host operating system, browser version, settings, hardware, power source, and headless mode. Its visual-comparison feature waits for two consecutive screenshots to match before comparing against a baseline, but that does not eliminate differences caused by changing environments. See Playwright’s visual comparisons documentation and run comparisons in a stable setup.

Troubleshooting

  • The screenshot is blank or incomplete: the app may not have rendered the route’s data yet, or the URL may be wrong. Confirm the page URL and wait for an app-specific selector or ready state before capturing.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    Rank #4
    Sale
    UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
    • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
    • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
    • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
    • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
    • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
  • Images or fonts are missing: they may load after the initial navigation signal. Wait for the relevant content to appear, verify asset requests succeed, and capture only after the state needed for the image is present.

  • The image cuts off the page: the default is a viewport capture. Use fullPage: true for the full document, or capture a specific element when only one component is needed.

  • The output dimensions are unexpected: check the configured viewport and the screenshot scale. CSS-pixel scale and device-pixel scale produce different output pixel counts.

  • A visual test differs across machines: browser versions, operating systems, hardware, and headless settings can affect rendering. Align those variables and use Playwright’s screenshot comparison workflow rather than assuming every environment produces identical pixels.

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
    Best Value
    Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
    • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
    • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
    • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
    • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
    • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
  • The browser does not launch: ensure the browser binary is installed for the Playwright version in use, for example with npx playwright install chromium, and consult that version’s setup guidance if the runtime environment requires additional configuration.

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

Or skip the browser setup

ScreenshotNeo takes a screenshot from a single GET request. The example saves a PNG; see the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://your-react-app.example -d format=png -o react-page.png

ScreenshotNeo removes cookie banners, newsletter popups, and chat widgets before capture, and each of those cleanup steps can be turned off. Bot checks, blank pages, failed loads, timeouts, and cache hits are not billed; response headers identify the page verdict and whether the request was billed. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The Free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

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

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

Frequently Asked Questions

Can I capture a React component without taking a screenshot of the whole page?

Yes. Use Playwright’s locator screenshot method on the component’s selector; the element-capture example above shows the pattern.

Does taking a screenshot export the React component as an image without running the app?

No. The screenshot captures browser-rendered pixels, so the page must be loaded and rendered in a browser.

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.