Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsSlow PC?RecommendedPC slow today? Run a repair scan before it gets worseResolve common Windows issues and optimize system performance.Scan Now×
Skip to content
World desk6 min

How to Run Puppeteer on Netlify

Run Puppeteer on Netlify by pairing a Node.js Function with a compatible Chromium executable, packaging dependencies, and testing the deployed runtime—not just your local browser.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Run Puppeteer inside a Node.js Netlify Function and deploy a Chromium executable that works in Netlify’s Linux runtime. A practical approach is puppeteer-core with @sparticuz/chromium: use the Chromium package’s launch arguments and executable path, and confirm both packages are included in the deployed function. Netlify’s own browser-prerendering example uses this pairing. Passing locally is not proof of deployment success; test the deployed function as well.

Choose a browser deployment strategy

Puppeteer needs a browser executable. puppeteer-core does not download one for you, so provide a compatible Chromium separately and pass its path to launch. The puppeteer package downloads its preferred browser during installation, but that browser must still make it into the deployed function artifact. Puppeteer documents the executable-path approach in its configuration guide.

As an Amazon Associate I earn from qualifying purchases.

Approach What to check
puppeteer-core plus @sparticuz/chromium Match the Chromium package version to the browser version supported by Puppeteer; include the binary and dependencies in the function bundle. The Chromium package is Linux-only. Its README says the compressed bundle is over 50 MB and describes @sparticuz/chromium-min with a separately hosted pack for size-constrained deployments.
puppeteer with its downloaded browser Ensure installation and deployment preserve the downloaded browser in the function artifact. Do not assume that installing Puppeteer alone makes a usable browser available in production.

For local development on macOS or Windows with the Linux-only @sparticuz/chromium binary, use a locally installed browser locally and the serverless binary in the deployed environment. Pin package versions in a lockfile and check the Chromium compatibility guidance when upgrading. Package sizes and platform limits can change, so verify the current package and your project’s deployment limits.

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

Create a Netlify Function

Netlify’s default functions directory is netlify/functions/, and a function named capture.js is normally available at /.netlify/functions/capture. The following CommonJS example uses puppeteer-core and @sparticuz/chromium; it accepts a URL in a JSON POST body and returns the captured page title. It illustrates browser launch and navigation, not screenshot or PDF output.

#1 Best Overall
// netlify/functions/capture.js
const chromium = require('@sparticuz/chromium');
const puppeteer = require('puppeteer-core');

exports.handler = async (event) => {
  if (event.httpMethod !== 'POST') {
    return { statusCode: 405, body: 'Method Not Allowed' };
  }

  let input;
  try {
    input = JSON.parse(event.body || '{}');
  } catch {
    return { statusCode: 400, body: 'Invalid JSON body' };
  }

  let target;
  try {
    target = new URL(input.url);
  } catch {
    return { statusCode: 400, body: 'Provide a valid URL' };
  }

  // Restricting schemes is a useful minimum; production services should
  // also validate destinations to prevent requests to private/internal hosts.
  if (!['http:', 'https:'].includes(target.protocol)) {
    return { statusCode: 400, body: 'URL must use HTTP or HTTPS' };
  }

  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(target.href, { waitUntil: 'domcontentloaded', timeout: 30000 });
    const title = await page.title();

    return {
      statusCode: 200,
      headers: { 'content-type': 'application/json; charset=utf-8' },
      body: JSON.stringify({ title }),
    };
  } catch (error) {
    console.error('Puppeteer function failed:', error);
    return { statusCode: 502, body: 'Unable to load the requested page' };
  } finally {
    if (browser) await browser.close();
  }
};

The example uses the serverless package’s launch configuration rather than hard-coded Chromium flags. The URL validation is only a starting point: a public endpoint that accepts arbitrary URLs can be abused to reach internal services, so validate allowed hosts or destinations for your use case.

Install and package dependencies

Install puppeteer-core and @sparticuz/chromium in the project that Netlify builds, and commit the resulting lockfile. Netlify CLI documentation notes that dependencies in separate, unbundled function folders are not recursively installed by the build system; its documented options include installing them during deployment with a prebuild or postinstall script. Check the current dependency-management documentation and make sure your actual function artifact contains the modules and browser.

Test locally, then test the deployed function

  1. Run the project’s normal dependency installation from the repository root and confirm the lockfile reflects the chosen package versions.
  2. Start Netlify Dev or the local functions server, then POST JSON such as {"url":"https://example.com"} to http://localhost:8888/.netlify/functions/capture.
  3. Confirm the response is JSON with a title. Local success checks your handler and local browser setup; it does not prove the Linux Chromium binary is present in the deployed artifact.
  4. Deploy, then POST the same request to https://YOUR_SITE/.netlify/functions/capture. Inspect the function’s logs and metrics if launch, navigation, or output generation fails. Netlify documents function monitoring in its function monitoring guide.

Netlify Functions run in an ephemeral runtime environment. Do not rely on local filesystem state surviving between invocations; return generated output in the response or use an appropriate storage design.

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 #2
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
  • 256 GB SSD of storage.
  • Multitasking is easy with 16GB of RAM
  • Equipped with a blazing fast Core i5 2.00 GHz processor.

Check runtime limits and workload fit

Netlify’s configuration documentation lists a 1024 MB default function memory allocation and a 60-second synchronous execution limit. Memory is configurable; the cited documentation says the synchronous limit is not configurable. These are documented function configuration limits, not guarantees that any particular Puppeteer workload will complete within them. Check your project and account settings before relying on exact limits.

Large pages, slow navigation, and PDF generation can consume substantial time and memory. Use timeouts appropriate to the page, avoid waiting for more browser activity than the task requires, and assess the workload against the function limits. If the job cannot reliably finish synchronously, use an architecture suited to longer work rather than assuming a browser launch will fit.

Troubleshooting common failures

  • “Could not find Chrome” or executable launch failure: The browser is missing from the deployed artifact, or the path is not configured. With a separately managed browser, pass its executable path and use the serverless package’s launch arguments.
  • Works locally but fails after deploy: Your local browser may differ from the Linux production browser, or deployment may have omitted the function dependencies. Test the deployed function and inspect its logs; verify the artifact contains the compatible binary and packages.
  • Incompatible browser or protocol errors: Puppeteer expects a corresponding browser version. Check the Puppeteer supported browsers information and the @sparticuz/chromium project documentation, then align and pin versions.
  • Function times out: Navigation may be slow, the page may keep connections active, or the task may be too large for a synchronous invocation. Choose a navigation condition that matches the task, set an explicit navigation timeout, and assess memory and execution limits.
  • Module not found in deployment: Dependencies may be outside the build’s dependency-install scope, especially in a separate unbundled function directory. Use the documented deployment installation approach or configure bundling so required modules reach the artifact.
  • Local development fails on macOS or Windows with serverless Chromium: The @sparticuz/chromium executable is for Linux. Use a local browser for local runs and the serverless binary in Netlify.
  • Package or deploy artifact is too large: The Chromium README describes its compressed bundle as over 50 MB and offers @sparticuz/chromium-min with a separately hosted pack for constrained environments. Verify current Netlify size limits and package instructions before switching.
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 the goal is a website screenshot rather than custom browser automation, ScreenshotNeo provides a screenshot API and MCP server. One GET request can return a PNG, JPEG, WebP, or PDF. See the ScreenshotNeo API documentation.

Rank #3
15.6 Inch Win 11 Laptop Computer, N4020, 4GB DDR4 RAM, 128GB Storage
  • WINDOWS 11 | STABLE PERFORMANCE: Powered by Intel Celeron N4020 processor and Windows 11 system, this laptop delivers stable performance for everyday computing tasks. It supports web browsing, online learning, document editing, email communication, and basic office work with optimized power efficiency, providing a practical and reliable experience for essential daily use for daily use.
  • 15.6” FHD IPS DISPLAY: Features a 15.6-inch Full HD IPS display with narrow bezels, offering wider viewing angles and clearer image details compared to standard panels. The improved screen-to-body ratio enhances visual experience for study, reading, document work, and video playback, making it suitable for both productivity and entertainment use.
  • 4GB DDR4 + 128GB eMMC STORAGE: Equipped with 4GB DDR4 memory and 128GB eMMC storage for everyday basics such as browsing, documents, email, and online learning platforms. The built-in TF card slot supports storage expansion up to 1TB, giving you more flexibility for files, photos, videos, and daily documents. TF card not included.
  • CONNECTIVITY & PORTS: Includes 1× TF card slot, 2× USB 3.2 Gen1 ports, and 2× full-featured Type-C ports (USB 3.2 Gen1). The Type-C ports support data transfer, charging, and video output, enabling flexible connection with external devices such as monitors, storage, and peripherals for daily work and study use.
  • LIGHTWEIGHT DESIGN | ONLINE COMMUNICATION: Designed with a slim, portable profile, this laptop is easy to carry for school, commuting, and travel. A built-in 1MP front camera supports online classes, video meetings, remote communication, and everyday conferencing. The 3300mAh battery works with the low-power system design to support practical daily use, while thermal optimization helps maintain quieter operation during extended tasks.
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp

ScreenshotNeo removes cookie/consent banners, newsletter popups, and chat widgets before capture. Bot checks, blank pages, and failed loads are not billed. Its MCP server lets AI agents use screenshot tools, and the Free plan includes 1,000 screenshots a month with no card; paid plans start at $5 for 3,000. Sign up for free.

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

Frequently Asked Questions

Can I use Puppeteer in a Netlify Function?

Yes. Run it in a Node.js function and make sure a compatible Chromium executable and the required dependencies are included in the deployed artifact.

Does Netlify’s default function directory have to be configured?

No. Netlify’s default directory is netlify/functions/; projects can use a configured functions directory instead.

Quick Recap

Bestseller No. 1
HP 14' HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
HP 14" HD Laptop, Windows 11, Intel Celeron Dual-Core Processor Up to 2.60GHz, 4GB RAM, 64GB SSD, Webcam, Dale Pink (Renewed)
14" diagonal, 1366x768 resolution, HD BrightView LED, Glossy NON-TOUCH Display
$245.99
Bestseller No. 2
Dell Latitude 5420 14' FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
Dell Latitude 5420 14" FHD Business Laptop Computer, Intel Quad-Core i5-1145G7, 16GB DDR4 RAM, 256GB SSD, Camera, HDMI, Windows 11 Pro (Renewed)
256 GB SSD of storage.; Multitasking is easy with 16GB of RAM; Equipped with a blazing fast Core i5 2.00 GHz processor.
$285.00

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.

Leave a Reply

Your email address will not be published. Required fields are marked *

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

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Crashes, No Sound, or Screen Glitches?Free driver scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.