connectOverCDP
to connect to a hosted browser (Kernel) and keep your code and API routes on Vercel.
The Error
If you’re seeing this error on Vercel:The Solution
Instead of launching a local browser, connect to a remote browser via CDP (Chrome DevTools Protocol):Environment Variables
Add your Kernel API key to Vercel:Toggle Between Local and Remote
For local development, you can use local Playwright. For production on Vercel, use Kernel:Why This Works
Vercel’s serverless functions have limitations:- No filesystem for binaries: Chromium requires ~300MB of binaries that can’t be bundled
- Cold start constraints: Functions need to start in <10s
- Read-only filesystem: Can’t install or cache browser binaries at runtime
Native Vercel Integration
For a seamless setup, install Kernel from the Vercel Marketplace. This provides:- One-click API key provisioning
- Automatic QA checks on every deployment
- Configuration management via Vercel dashboard
FAQ
Can I run Playwright on Vercel?
You cannot launch a local Chromium binary inside Vercel’s serverless functions. However, you can use Playwright’sconnectOverCDP
method to connect to a remote browser hosted by Kernel. Your Playwright code runs on Vercel; the browser runs on Kernel.
Do I need to change my existing Playwright code?
Minimal changes. Replacebrowser.launch()
with chromium.connectOverCDP()
and connect to Kernel’s CDP endpoint. The rest of your Playwright code (page navigation, selectors, actions) remains identical.
What about playwright install
?
You don’t need to run playwright install
on Vercel. Use playwright-core
(which doesn’t include browser binaries) and connect to Kernel’s hosted browsers instead.
Does this work with Puppeteer too?
Yes! Puppeteer also supports CDP connections:How much does it cost?
Kernel charges per-minute of active browser time. See pricing for details. Most API routes run in seconds, costing fractions of a cent per request.Related Resources
- Vercel Integration Guide
- Network Interception on Serverless
- Playwright Timeouts on Serverless
- Create a Browser
Troubleshooting
Still seeing errors? Check:KERNEL_API_KEY
is set in Vercel environment variables- Using
playwright-core
(notplaywright
) in package.json - Using
chromium.connectOverCDP()
(notchromium.launch()
) - Awaiting the connection before using the browser