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.

To export a rendered React component as a downloadable JPG in the browser, capture its DOM element with html2canvas, encode the returned canvas as JPEG, and trigger a download. This is a convenient client-side approach for ordinary components, but it reconstructs the page from DOM and CSS rather than taking a native browser screenshot, so verify the result when visual fidelity matters.

Export a React element as a JPG

Install html2canvas in your React project:

npm install html2canvas

Then attach a ref to the element you want to export. Call html2canvas after React has rendered that element, convert the canvas to JPEG, and download it through a temporary anchor:

import { useRef, useState } from 'react';
import html2canvas from 'html2canvas';

export function DownloadCard() {
  const cardRef = useRef(null);
  const [error, setError] = useState('');
  const [busy, setBusy] = useState(false);

  async function downloadJpg() {
    const element = cardRef.current;
    if (!element || busy) return;

    setError('');
    setBusy(true);

    try {
      const canvas = await html2canvas(element, {
        scale: window.devicePixelRatio || 1,
        useCORS: true,
        backgroundColor: '#ffffff',
      });

      const link = document.createElement('a');
      link.download = 'card.jpg';
      link.href = canvas.toDataURL('image/jpeg', 0.92);
      link.click();
    } catch (err) {
      console.error('JPG export failed:', err);
      setError('Could not create the image. Check external assets and try again.');
    } finally {
      setBusy(false);
    }
  }

  return (
    <section>
      <div ref={cardRef}>
        <h2>A card to export</h2>
        <p>This rendered element will become a JPG.</p>
      </div>
      <button type="button" onClick={downloadJpg} disabled={busy}>
        {busy ? 'Preparing image…' : 'Download JPG'}
      </button>
      {error && <p role="alert">{error}</p>}
    </section>
  );
}

The JSX tags in the example’s return should be ordinary JSX tags in a source file; they are escaped here so the HTML article can display them. The example’s error state gives the user feedback if capture or canvas encoding fails. You can remove it for a minimal implementation, but retaining a visible failure message is useful for real exports.

Choose the capture target deliberately

Place the ref on the smallest element that contains all the content intended for the image. If the ref is attached to a wrapper containing navigation, buttons, or unrelated page content, those items will be captured too. The ref is null until React mounts the element, so run the capture only from an event handler or another point after rendering.

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.

Control sharpness and file size

scale: window.devicePixelRatio increases the canvas dimensions on high-density displays, which can make text and details sharper. It also increases memory use and can make a large capture fail. For a smaller output, use scale: 1; for a specific export size, choose a fixed scale and design the element’s CSS dimensions accordingly. The canvas’s pixel dimensions are the element’s CSS dimensions multiplied by the scale.

The JPEG quality argument is between 0 and 1 in the browser canvas API. A value such as 0.92 is a practical starting point, not a guarantee of a particular file size or visual result. JPEG is lossy and does not preserve transparency. The example supplies a white background to avoid an unexpected transparent area being flattened to a browser-dependent color. Use PNG instead if transparency or lossless output is required:

link.download = 'card.png';
link.href = canvas.toDataURL('image/png');

Know what html2canvas does—and does not do

html2canvas is a browser-side library that takes a DOM element and resolves to a canvas. It is not suitable for Node.js. It reconstructs an image from DOM information and the CSS it understands; it does not take a native screenshot of the browser’s rendered pixels. Some styling or content may therefore be absent or look different from the live page. See the html2canvas documentation and FAQ.

If the exported card is slightly different from the browser, inspect which styles and assets are actually supported and rendered. If you need a faithful capture of actual browser output, full-page capture, server-side capture, or consistent automation, a real-browser tool such as Playwright or Puppeteer is a better direction. Playwright documents JPEG screenshots and a quality option in its screenshot guide. Browser automation adds setup and execution requirements that a client-side canvas export does not.

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.

Handle images, fonts, and other assets before capture

Capture only after the content has rendered and its required images and fonts have loaded. The exact readiness logic depends on how the application loads those assets; there is no universal React wait that guarantees every asynchronous resource is ready. For an image-based component, you can wait for its image elements before calling html2canvas:

async function waitForImages(element) {
  const images = [...element.querySelectorAll('img')];
  await Promise.all(images.map((img) => {
    if (img.complete) return Promise.resolve();
    return new Promise((resolve) => {
      img.addEventListener('load', resolve, { once: true });
      img.addEventListener('error', resolve, { once: true });
    });
  }));
}

This waits for the selected <img> elements to load or fail; it does not certify that CSS background images, fonts, or content inside other browsing contexts is ready. Handle those separately if the exported design depends on them. A failed asset should not silently be treated as a successful visual export.

Cross-origin images and canvas security

Remote images may be omitted or cause the canvas to become unreadable if the image host does not permit cross-origin access. Setting useCORS: true asks the library to use CORS for eligible images; it cannot override browser security policy. The server hosting the image must send suitable CORS headers. The html2canvas FAQ explains the restriction: “html2canvas cannot circumvent browser content policy restrictions.” See its cross-origin guidance.

If you control the image host, configure its CORS response appropriately. Otherwise, a carefully designed same-origin proxy may be an option, but it creates a security boundary: do not expose an unrestricted endpoint that fetches arbitrary URLs. Cross-origin iframes are inaccessible to html2canvas under browser security rules; use a real-browser workflow or change how that content is served if it must be included.

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.

When to use a different capture approach

Need Approach Trade-off
Export a straightforward React component in the user’s browser html2canvas Simple client-side flow, but output is reconstructed and may differ from the browser display.
Capture actual browser-rendered pixels or an element using browser automation Playwright screenshot API Real browser rendering, with browser automation setup and execution to manage.
Generate screenshots on a server Playwright or Puppeteer Suitable beyond a client-only library’s model, but deployment must support browser execution.
Produce paginated print output or selectable text A browser/PDF workflow JPG is a raster image, not a paginated document format.

Choose based on where capture should run, how closely the output must match the browser, whether you control external assets, the required output format, and the operational complexity you can support. There is no numeric performance comparison established here; measure your own page and target browsers rather than assuming one approach is faster.

Troubleshoot common export failures

The button does nothing or the ref is null

Confirm that the ref is attached to a rendered element and that the handler runs after mount. If the capture button is disabled while busy, ensure the state is reset in a finally block as in the example, including after a rejected promise.

The image is blank or missing remote pictures

Check whether the source images load in the page and whether their servers send CORS headers that permit use by your app’s origin. Keep useCORS: true, but do not treat it as a bypass. For content you cannot serve with suitable cross-origin permissions, consider a safe same-origin asset arrangement or a real-browser screenshot approach.

Styles or content differ from the page

Because html2canvas reconstructs the image rather than capturing native browser pixels, unsupported or incompletely represented CSS can affect the result. Reduce the capture to a simpler element, check the library’s documented behavior, or switch to Playwright/Puppeteer when matching the actual rendered page is essential.

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 #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

Canvas encoding throws a security error

A tainted canvas cannot be read with toDataURL. This commonly follows drawing a cross-origin asset without the required permission. Fix the resource’s CORS configuration or remove the asset from the export; changing the JPEG quality or filename will not resolve a security restriction.

The output is blank, partial, or capture fails on a large element

Browsers impose canvas size and memory limits that vary by browser, platform, and hardware; there is no single safe maximum for every user. Reduce the target dimensions or scale, capture smaller sections, or use a browser automation workflow suited to the desired page capture. Increasing scale raises both output dimensions and memory consumption.

The JPG looks soft or has an unwanted background

Increase scale only if the target device can handle the larger canvas, and explicitly set a background color when the design should not appear transparent. JPEG introduces lossy compression; if artifacts are unacceptable or transparency is required, export PNG instead.

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 public webpage rather than export a component inside your React app, ScreenshotNeo can return an image or PDF with one GET request. Its API can capture a URL as PNG, JPEG, or WebP, and its other options include full-page capture, element selection by CSS selector, viewport and device settings, custom CSS or JavaScript, waits for a selector or network idle, and PDF settings. See the API documentation for request parameters and response details.

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.
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, and each of those steps can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed; response headers report the page verdict and billing status. An MCP server provides screenshot tools for AI agents, including Claude, Cursor, and other MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

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

Frequently Asked Questions

Can html2canvas run in a Node.js React application?

No. It is a browser-side library and is not suitable for Node.js. Use browser automation such as Playwright or Puppeteer for server-side capture.

Can I export a transparent JPG from React?

No. JPEG does not preserve transparency. Use PNG when the output needs a transparent background.

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

Does useCORS: true let me capture any remote image?

No. The image server must permit cross-origin access with suitable CORS headers; the option cannot bypass browser security 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.