To take a Playwright screenshot in AWS Lambda, package a Chromium build and its Linux dependencies in a Lambda-compatible deployment, navigate to the page, save the image under the writable /tmp directory, then return the bytes or upload them to durable storage such as Amazon S3. The capture call is simple; making the browser binary, architecture, filesystem, and output path work together is the deployment challenge.
Capture a page with Playwright
Playwright’s Page API supports navigating to a URL and saving a screenshot with page.screenshot({ path: ... }). The following Node.js handler shows the basic flow, including cleanup if navigation or capture fails. It is an application outline, not a complete deployable Lambda package: the Chromium executable, launch flags, system libraries, output destination, URL validation, and error policy depend on the browser build and deployment you choose. See the Playwright screenshot documentation.
const { chromium } = require('playwright');
exports.handler = async (event) => {
let browser;
try {
browser = await chromium.launch({ headless: true });
const page = await browser.newPage();
await page.goto(event.url, { waitUntil: 'load' });
const image = await page.screenshot({ path: '/tmp/screenshot.png' });
// Upload image to S3 or return it according to your invocation interface.
return { statusCode: 200, body: 'Screenshot captured' };
} finally {
await browser?.close();
}
};
Here, image contains the screenshot bytes as well as the file being written. The sample does not return those bytes to the caller; choose an output method that fits your invocation type and payload size. Closing the browser in finally prevents a reused Lambda execution environment from retaining browser resources after an error.
Choose how to package Chromium
Lambda does not make a local Playwright browser installation automatically compatible. You must supply a Chromium executable that matches the function’s Linux environment and CPU architecture, along with its required shared libraries. The AWS deployment documentation describes supported container-image workflows and the runtime requirements: AWS Lambda container images for Node.js.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minute#1 Best Overall
- 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.
Container image
A container image is often the most direct option when Chromium and its system libraries make a ZIP package cumbersome. Include the application, Playwright runtime, browser executable, and required libraries in a Lambda-compatible image. AWS base images include Lambda runtime components; if you use another base image, it needs the appropriate runtime interface client. The image must tolerate a read-only filesystem except for /tmp, and its browser files must be readable and executable by Lambda’s default least-privileged user. See AWS image requirements.
Build for one target architecture—linux/amd64 or linux/arm64—matching the Lambda function. Push the image to Amazon ECR in the same AWS Region as the function. Pushing a changed image to an existing tag alone does not update the deployed function; update the function’s code after publishing the image. Runtime base-image tags and supported runtimes change, so verify the current AWS guide when selecting and pinning a base image.
ZIP package or Lambda layer
A ZIP and layer can work if the browser and libraries fit the package limits and were built for a compatible Linux environment and architecture. Browserless published a vendor-authored DIY ZIP/layer example on April 29, 2024, alongside a hosted-browser option; treat its specific commands as dated implementation guidance and verify them against the current Lambda runtime before adopting them: Browserless Lambda article.
Rank #2
- 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.
The playwright-aws-lambda package listing describes an older Chromium-only integration and names runtimes through Node.js 20. That package-specific historical description is not a guarantee of current compatibility; check its maintenance status, browser version, target architecture, and runtime support before relying on it: npm package listing.
Free tools Windows power users keep installed
One-click scans. No signup required.
Hosted browser
A hosted browser can keep Chromium out of the Lambda package, but adds a network dependency and vendor operational and data-handling considerations. The cited implementation article describes this as an alternative; the available evidence does not establish comparative speed, price, or suitability for every workload. Compare it with self-hosting using representative pages and your own service requirements.
Wait for the right page state
The example uses waitUntil: 'load', which waits for the page load event. That may be enough for a simple document, but many applications render important content asynchronously. For those, wait for a meaningful locator or application-specific readiness condition before capturing. Avoid substituting a long arbitrary sleep when the page exposes a condition you can wait for. There is no universal readiness signal for every website; choose and validate one for the page you capture.
Rank #3
- 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.
Save and deliver the screenshot
Use /tmp only as temporary storage
Lambda’s /tmp directory is writable, unlike the rest of the container image filesystem, but it is temporary storage rather than durable object storage. Save the image there for processing, then upload it to S3 if it must remain available after the invocation. Grant the function only the S3 permissions it needs.
Return bytes only when the invocation supports them
You can return image bytes through a caller interface that supports the response format and size. For ordinary buffered synchronous Lambda invocations, AWS documents a 6 MB request and response payload quota; streamed responses have separate limits. Larger screenshots are generally better uploaded to S3, with the function returning an object reference instead. Check the current Lambda quotas for the invocation type you use.
Size the function for browser work
A browser screenshot consumes CPU, memory, temporary disk, and execution time. AWS documents these configurable Lambda ranges and artifact limits; they are limits, not recommended settings for every capture:
Rank #4
- 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
| Resource or limit | Documented value | What it means for screenshot workloads |
|---|---|---|
| Function timeout | Up to 900 seconds (15 minutes) | Allow time for startup, navigation, rendering, capture, and transfer; do not assume the maximum is needed. |
| Memory | 128 MB–10,240 MB | CPU allocation rises with memory. Measure representative pages and tune for browser rendering rather than assuming the minimum is enough. |
/tmp storage |
512 MB–10,240 MB | Account for browser cache and temporary outputs as well as the screenshot. |
| ZIP deployment contents, uncompressed | 250 MB maximum, including layers | Chromium and libraries can make this limit restrictive. |
| Container image, uncompressed | 10 GB maximum | Offers more room for browser dependencies than a ZIP deployment. |
| Buffered synchronous response | 6 MB request and response payload quota | Use durable storage and return a reference when the image is too large for the response path. |
These figures are from AWS’s Lambda quotas documentation. Check it again when deploying because service limits and runtime support can change. For performance and reliability, record startup, navigation, capture, and upload time separately on representative pages; the available documentation does not provide an apples-to-apples benchmark for ZIP, image, and hosted-browser approaches.
Protect the function and handle failures
If callers supply a URL, validate it for your use case and restrict destinations as appropriate. An unrestricted screenshot endpoint can become a fetch proxy to destinations you did not intend to expose. Return controlled errors for browser startup, navigation, and capture failures, and apply least-privilege IAM permissions to any storage destination. These are implementation safeguards; the cited Lambda and Playwright documentation do not provide a complete threat model for a screenshot service.
- Reject malformed or disallowed URLs before launching Chromium.
- Use a timeout and an explicit readiness condition suited to the target page.
- Close the browser in cleanup on both success and failure.
- Keep durable output in S3 or another appropriate storage service, not solely in
/tmp.
Troubleshoot common deployment problems
| Symptom | Likely cause | What to check |
|---|---|---|
| Browser fails to launch | Wrong executable, missing Linux shared library, incompatible browser build, or launch configuration | Confirm the Chromium path and required libraries are included in the artifact and match the Lambda Linux environment and architecture. |
| Works locally but fails in Lambda | Local OS, architecture, permissions, or filesystem differs from the deployed environment | Build for the function’s architecture; verify browser files can be executed by Lambda’s default user and write outputs only to /tmp. |
| Image is missing or cannot be written | Output path points outside writable temporary storage, or /tmp capacity is insufficient |
Use a path such as /tmp/screenshot.png and configure enough ephemeral storage for the workload. |
| Screenshot is blank or incomplete | Navigation completed before the application finished rendering | Wait for a page-specific locator or readiness condition instead of relying on load alone. |
| Invocation times out | Slow navigation, rendering, browser startup, or output transfer; insufficient configured timeout | Measure each stage, set a suitable timeout with headroom, and tune memory against representative pages. |
| Deployment package is rejected | ZIP contents exceed the uncompressed limit or image architecture does not match the function | Reduce ZIP dependencies or use a container image; build and deploy for the configured architecture. |
| Updated image tag has no effect | The function still points to its previous deployed image version | After pushing the image, update the Lambda function code to use the new image. |
| Response fails for a large image | Buffered synchronous response exceeds the documented payload quota | Upload to S3 and return a reference, or use an invocation method with an appropriate response path. |
Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server from Yorker Media. One GET request can return a PNG, JPEG, WebP, or PDF, without packaging Chromium in your Lambda function. For example, save a WebP screenshot of Stripe with cURL:
Best Value
- 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
See the ScreenshotNeo API documentation for authentication and request options. Its cleanup accepts cookie or consent banners and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each cleanup step can be turned off. Bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits are not billed, and responses identify the page verdict and billing status in headers. An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for Claude, Cursor, and other 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 try 1,000 screenshots a month without a card.
Frequently Asked Questions
Does Playwright’s screenshot method return image bytes as well as save a file?
Yes. When you call page.screenshot(), its result can be used as image bytes; the path option also writes the screenshot to a file.
Can I use AWS Lambda’s Node.js 20 base image for this?
AWS’s current Node.js image guidance identifies supported base images, but runtime support changes. Check the AWS guide and its current tags when choosing the runtime; the older playwright-aws-lambda package listing is not assurance of compatibility.
Do these 3 things before closing this tab:
1Fix the driver behind crashes, sound loss and screen glitches2Repair Windows errors before they cause bigger problems3Scan for outdated or missing drivers - takes under a minuteQuick Recap
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.

