The Edge Runtime

V8-Based, Fast Cold Starts, Node API Subset

The Edge Runtime

The Edge Runtime is a V8 sandbox with Web Standards APIs — fast, deployable to CDN PoPs, and missing some Node APIs.

4 min read Level 3/5 #nextjs#edge#runtime
What you'll learn
  • Opt a route in with `export const runtime = 'edge'`
  • Know what you give up (`fs`, `child_process`, native modules)
  • Pick edge for low-latency endpoints

The Edge Runtime is the same V8 sandbox that powers Vercel Edge Functions, Cloudflare Workers, and Next middleware. It is fast to cold-start and runs at the network edge — close to your users.

Opt a Route Into Edge

// app/api/ping/route.ts
export const runtime = 'edge'

export async function GET() {
  return Response.json({ pong: true })
}

Middleware always runs on the Edge; for everything else you opt in per route.

What Works

  • fetch, Request, Response, URL, URLSearchParams
  • crypto.subtle and the Web Crypto APIs
  • TextEncoder / TextDecoder
  • ReadableStream, TransformStream
  • Most modern ORMs with HTTP-based drivers (Neon, Turso, PlanetScale)

What Does Not

  • fs, child_process, net, and other Node-only modules
  • Native node modules (.node addons)
  • ORMs that use TCP-based drivers without an HTTP fallback

If your dependency tree pulls in any of those, the build will tell you.

When to Use It

Pick Edge for routes where latency matters more than feature set: redirects, geo-aware APIs, authentication checks, OG image generation. Keep heavier Node-only routes on the default Node runtime.

// Default runtime — full Node API
export const runtime = 'nodejs' // implicit
Streaming Data With async iterators →