Vercel Edge Functions
Run Nimbus license checks at the edge — zero cold starts, global latency under 50ms.
Why edge?
Edge functions execute in Vercel's global runtime, close to your users. A license validation that takes 200ms from us-east-1 drops to 30ms when it runs in Frankfurt, Tokyo, or Sydney.
Middleware pattern
Place a middleware.ts at your project root. It fires on every request before your pages render.
export const config = {
matcher: ['/dashboard/:path*'],
}
export default function middleware(req) {
const token = req.headers.get('x-nimbus-key')
if (!token) {
return new Response('Missing license', { status: 401 })
}
// call Nimbus edge validator here
}Nimbus edge validator
The edge validator is a lightweight fetch to Nimbus's globally replicated KV store. No database round-trip — just a key lookup.
const res = await fetch(
'https://api.getnimbus.net/edge/validate',
{
headers: {
'x-license-key': token,
'x-fingerprint': req.headers.get('x-nimbus-fp'),
},
}
)
if (!res.ok) {
return new Response('License invalid', { status: 403 })
}Caching the result
Cache a successful validation for 60 seconds in a cookie or header so repeat requests skip the edge call entirely. Combine with stale-while-revalidate for the best UX.
Pro tip: Pair edge validation with Nimbus's offline grace cache. If the edge call fails (network blip), fall back to a signed local cache entry — your users never see a license error.