An Edge Function on every path of your Netlify site. Crawlers (search engines, AI crawlers, link previews) get the page prerendered by Prebaked; visitors get your site unchanged.
What it does
Same rules as the Cloudflare Worker:
- Prerenders only
GET/HEADrequests from a known crawler user agent. Static files, other methods and requests carryingX-Prerendergo to your site. - Calls
GET https://service.prebaked.io/<full page URL>withX-Prerender-Token. - Passes Prebaked's 200, redirects, 404 and 410 to the crawler.
- Serves your normal page (
context.next()) when Prebaked cannot be reached, takes longer than 5 seconds, or answers 401/403, 400 or 5xx.
1. Copy the files
Into your site repository, keeping the paths:
netlify/edge-functions/prebaked.ts(the function;config.pathis/*)netlify/lib/prebaked-edge.ts(bot detection, service URL, fallback; no dependencies)
2. Set the environment variables
In the Netlify UI (Site configuration > Environment variables) or with the CLI:
netlify env:set PREBAKED_SERVICE_URL https://service.prebaked.io/
netlify env:set PREBAKED_TOKEN <your token> --secretWithout either variable every request goes to your site.
3. Deploy and check
Deploy as usual, then:
curl -A "Googlebot" https://www.<your-domain>/ # rendered HTML
curl https://www.<your-domain>/ # your normal pageThe first crawler request appears in the Prebaked dashboard request log.
Notes
- The visitor IP (
context.ip) is sent asX-Forwarded-Forso Prebaked can verify crawler IPs. - Imports use the
.tsextension, as Deno (the Edge Functions runtime) requires.