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

To take Puppeteer screenshots on AWS Lambda, deploy a Linux-compatible Chromium build alongside a compatible Puppeteer package, configure writable browser paths, and save the result somewhere durable such as Amazon S3. A local Chrome installation is not a Lambda deployment: the browser binary, runtime, architecture, and package must work together. For ZIP or layer deployments, Puppeteer’s troubleshooting guide points Lambda users to Sparticuz Chromium; AWS also documents a container-image workflow, though its sample uses a historical Node.js 12 base image.

Choose a Lambda packaging approach

Decide how Chromium will reach the function before writing the handler. The practical choices are a container image, a complete Chromium package, or a smaller package whose browser assets are provided separately. Whichever route you choose, check current compatibility among the Lambda runtime, Linux environment, architecture, Chromium build, and Puppeteer version before pinning dependencies.

Approach What it involves Trade-off
Container image Package the function and its operating-system dependencies in an image. Useful when you want to bundle OS libraries with the application; the image still needs a currently supported Lambda runtime and compatible browser.
Full Chromium package Deploy the Chromium package and Puppeteer dependencies with a ZIP package or layer. Browser files travel with the deployment.
@sparticuz/chromium-min Deploy the smaller package and supply its Brotli browser files separately, for example from /opt/chromium. Can help with package-size constraints, but adds artifact and path management.

AWS’s container example illustrates a workflow: launch headless Chrome in a Lambda handler and write screenshots to S3. It also separates a fan-out function from workers that capture individual URLs. Treat it as an architectural example, not a current runtime recipe: its Dockerfile uses amazon/aws-lambda-nodejs:12. Adapt the workflow to a currently supported runtime and an appropriately scoped IAM role.

For ZIP and layer deployments, the Puppeteer troubleshooting guide directs Lambda users to Sparticuz Chromium. Its README covers the full and -min packages, asynchronous executable-path resolution, and recommended launch arguments. Check its current release notes and compatibility before selecting versions.

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.

Match the browser artifact to Lambda architecture

Sparticuz Chromium is Linux-specific. Its README says the npm package includes x64 binaries. For arm64, it describes using the -min package with a released arm64 Lambda layer or remote pack; it notes arm64 binaries are available starting with Chromium v135. Verify that the artifact you deploy matches the function’s configured architecture. A macOS or Windows browser binary from a development machine is not a substitute.

Build a handler that captures and stores a screenshot

The following pattern shows the important steps: resolve the Chromium executable asynchronously, launch Puppeteer with the package’s launch arguments, capture a page, and close the browser even if navigation or capture fails. It writes to Lambda’s temporary directory; upload that file to S3 or another durable destination if it must remain available after the invocation.

Install and pin mutually compatible versions of puppeteer-core and @sparticuz/chromium in your project. The package’s README is the authority for the current executable-path and launch-argument APIs; the code below follows the documented pattern, but check the README for changes before deployment.

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 chromium = require('@sparticuz/chromium');
const puppeteer = require('puppeteer-core');
const fs = require('node:fs/promises');
const path = require('node:path');

exports.handler = async (event) => {
  const url = event.url;
  if (!url) throw new Error('Pass a URL in event.url');

  let browser;
  try {
    browser = await puppeteer.launch({
      args: chromium.args,
      defaultViewport: chromium.defaultViewport,
      executablePath: await chromium.executablePath(),
      headless: chromium.headless,
    });

    const page = await browser.newPage();
    await page.goto(url, { waitUntil: 'networkidle0', timeout: 60000 });
    const outputPath = path.join('/tmp', 'screenshot.png');
    await page.screenshot({ path: outputPath, fullPage: true });

    // Upload outputPath to S3 or another durable destination here.
    return { statusCode: 200, body: JSON.stringify({ outputPath }) };
  } finally {
    if (browser) await browser.close();
  }
};

This is a handler pattern, not a complete S3 upload implementation: destination bucket, object key, IAM permissions, and retention policy depend on your application. AWS’s example demonstrates the S3 output workflow, but does not establish a current IAM policy for your deployment.

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

Choose navigation readiness deliberately

networkidle0 waits for network activity to settle, but pages with long-lived connections or continuous requests may not reach that state promptly. If the page exposes a reliable selector for the content you need, waiting for that selector can be more targeted. You can also use a bounded delay when the page behavior requires it. Keep navigation and waits bounded, and test against the actual pages your function will capture.

Handle multiple URLs

For a small batch, a handler can process URLs serially, subject to its timeout and memory budget. For larger workloads, the AWS example uses a fan-out function that asynchronously invokes per-URL screenshot workers. That separates orchestration from browser work; set concurrency and retry behavior to suit your application rather than assuming one function can safely handle an arbitrary batch.

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.

Make bundling and browser paths work

When using esbuild, webpack, Rollup, or a similar bundler with Sparticuz, externalize @sparticuz/chromium so it can resolve its relative browser resources at runtime. Sparticuz associates the error The input directory "/var/task/bin" does not exist with failing to externalize the package.

  • Inspect the deployed ZIP, layer, or image and confirm the selected Chromium package or external browser assets are actually present.
  • Verify that the executable-path resolver points to the path provided by your chosen package or layer.
  • If using -min, confirm the separately supplied Brotli files are available where the package expects them.
  • For arm64, verify that the selected layer or remote pack is built for the function’s architecture.

Lambda’s execution environment has locations that are not writable. Puppeteer documents setting XDG_CONFIG_HOME and XDG_CACHE_HOME to directories under /tmp; if needed, configure userDataDir there too. Apply these settings before launching the browser, and ensure the directories exist or can be created.

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

Configure fonts for the pages you capture

Do not assume Lambda has the fonts installed on a developer laptop. Sparticuz says its Chromium package includes Open Sans coverage for Latin, Greek, and Cyrillic. If pages use other scripts or require exact brand typography, provision the needed font faces separately, for example in a Lambda layer.

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

Sparticuz documents these font locations: /var/task/.fonts, /var/task/fonts, /opt/fonts, and /tmp/fonts. Confirm that your font files reach one of the supported locations and that the rendered page actually uses them; missing glyphs or fallback typography can otherwise make an otherwise successful screenshot look wrong.

Tune memory, timeout, and browser lifecycle

Lambda CPU allocation scales with configured memory, so increasing memory may help browser startup or page rendering, but there is no universal correct setting. Invocation time includes browser launch, navigation, page work, screenshot encoding, and downstream work such as uploading the image. Lambda stops a standard invocation at its configured timeout. Test representative pages—including the slow and resource-heavy cases you expect—and tune memory and timeout from observed behavior. AWS recommends testing realistic workloads up to their expected upper bounds.

Warm Lambda environments can preserve initialized global state between invocations. AWS notes that retained globals and some libraries can accumulate memory. Reuse only what is safe, track memory and duration across repeated invocations, and close pages and the browser when work is complete. Sparticuz notes that Chromium may open more pages than expected and recommends closing pages and awaiting browser closure if close operations hang. Keep browser cleanup in a finally block so errors do not skip it.

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.

There are no established universal cold-start, throughput, or cost figures for these packaging approaches. Compare them using your target runtime, region, architecture, page mix, and concurrency; measure startup and per-page time rather than extrapolating from a different workload.

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

Troubleshoot common errors

Symptom Likely cause and checks Practical fix
Chromium fails before Puppeteer connects; crashpad says --database is required. Chrome config, cache, or profile paths may not be writable. Set XDG_CONFIG_HOME and XDG_CACHE_HOME under /tmp; set userDataDir there if needed, then retry.
The input directory "/var/task/bin" does not exist. With Sparticuz and a bundler, the Chromium package may not have been externalized, or its resources may be missing from the deployed artifact. Externalize @sparticuz/chromium and inspect the deployed package and executable path.
Text or glyphs are missing or look different. The Lambda environment may lack the fonts used on the source page. Check the documented bundled Open Sans coverage; add required fonts through a layer or supported font directory.
The invocation times out. Timeout may be too short for browser startup, navigation, page complexity, data transfer, or downstream requests; configured memory also affects CPU allocation. Check CloudWatch Logs and duration, then test realistic pages while adjusting memory and timeout. Bound navigation and other waits.
Warm invocations slow down or consume more resources. Retained global state or libraries may accumulate resources; browser or page cleanup may be incomplete. Inspect retained state, close pages, and await browser.close() on success and error paths.
The screenshot file is missing. The handler may have failed before capture or before upload, or the output may only exist in temporary storage. Check the function’s CloudWatch Logs and error response. Verify the capture path and, if persistence is needed, the upload step and destination.

Diagnose the specific failure before adding launch flags or extending timeouts. Those changes do not fix an absent binary, incompatible architecture, unwritable paths, missing fonts, or an incorrectly bundled package.

Or skip the browser setup

If the goal is a screenshot rather than operating Chromium inside Lambda, ScreenshotNeo is a website screenshot API and MCP server. One GET request returns an image or PDF; its API is documented at ScreenshotNeo’s API documentation.

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

ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and the response includes X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and other MCP clients. The free plan includes 1,000 shots a month with no card; paid plans start at $5 for 3,000 shots. Sign up for the free plan.

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

Further reading

Frequently Asked Questions

Can I deploy the Chrome binary installed on my laptop to Lambda?

No. Deploy a browser build intended for Lambda’s Linux environment and matching its architecture and Puppeteer setup.

Does the AWS container example use a current Node.js runtime?

No. Its Dockerfile uses a Node.js 12 Lambda base image, so use it to understand the workflow, not as a current runtime template.

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.