Deploy Reader as Vercel Serverless Functions.
Running a full browser in Vercel Functions is not recommended due to:
- Cold start times
- Memory limits
- Binary size restrictions
- Execution time limits (10-30 seconds)
Recommended approach: Use a remote browser service.
-
Sign up for a browser service:
- Browserless
- Browserbase
- Or self-hosted
-
Set environment variable:
vercel env add BROWSER_WS_ENDPOINT # Enter: wss://chrome.browserless.io?token=YOUR_TOKEN -
Deploy:
vercel deploy
vercel-functions/
├── api/
│ └── scrape.ts # /api/scrape endpoint
├── package.json
└── vercel.json
{
"functions": {
"api/scrape.ts": {
"memory": 1024,
"maxDuration": 30
}
}
}{
"dependencies": {
"@vakra-dev/reader": "^1.0.0"
}
}curl -X POST https://your-app.vercel.app/api/scrape \
-H "Content-Type: application/json" \
-d '{"urls": ["https://example.com"]}'For better performance, use Vercel Edge Functions with a fetch-based approach:
// api/scrape-edge.ts
export const config = {
runtime: "edge",
};
export default async function handler(req: Request) {
// Use fetch to call Reader running elsewhere
const response = await fetch("https://your-reader.com/scrape", {
method: "POST",
body: req.body,
});
return response;
}This approach:
- Sub-second cold starts
- Global edge network
- Lower latency for users