Vercel Integration
April 20, 2026 ยท View on GitHub
Self-managed Vercel Routing Middleware that routes bot traffic to the ostr.io pre-rendering CDN. One file, zero config, works with any framework deployed to Vercel.
- Pre-rendering overview
- Rendering endpoints
- ๐ฆ Ready-to-use middleware + setup guide โ drop-in
middleware.js, env-var reference, deploy steps - ๐ Vercel Routing Middleware docs
What it does
Vercel Routing Middleware runs on every request before the CDN cache. The supplied middleware:
- Lets non-
GET/HEADtraffic pass through to origin unchanged. - Skips static assets and
/.well-known/paths. - Checks the
User-Agentagainst the canonical crawler regex and handles the legacy_escaped_fragment_query parameter. - For bot traffic, proxies the request to
https://render.ostr.iowith yourOSTR_AUTHheader. - On any renderer error, falls back to your origin response (fail-open).
When to use
- You deploy to Vercel and want pre-rendering without touching your framework code.
- You want edge-level routing โ middleware runs before the CDN cache.
- You use a framework that does not expose its own middleware hook, or you want a single integration that is independent of the framework (Astro, SvelteKit, Nuxt, Remix, plain static, etc.).
For Next.js specifically, the dedicated Next.js middleware / NPM package is another good option and runs in the same runtime.
Framework compatibility
The middleware is framework-agnostic. Works with any framework deployed to Vercel:
- Astro
- Next.js (also see the Next.js-specific integration)
- SvelteKit
- Nuxt
- Remix
- Plain static sites
Setup
The complete drop-in middleware, env-var reference, and deploy steps live in examples/vercel/. High-level flow:
- Copy
examples/vercel/middleware.jsto your project root. - Install
@vercel/functions. - Set
OSTR_AUTH(from the ostr.io pre-rendering panel) and, if needed,ROOT_URLas Vercel environment variables. - Deploy.
See the example README for full details.
Validation
Bot request should return a pre-rendered snapshot with the X-Prerender-Id header:
curl -sI -A 'Googlebot/2.1' https://yourdomain.com/
Regular browser request should pass through untouched:
curl -sI -A 'Mozilla/5.0' https://yourdomain.com/
Related
- Next.js integration โ Next.js-specific alternative
- Netlify integration โ same layer, different host
- Cloudflare Worker integration โ CDN-level alternative that does not require Vercel
- Detect pre-rendering engine requests at runtime
- Rendering endpoints