Careeroza
Edge vs Node.js Runtime
Two Runtimes
| Node.js runtime (default) | Edge runtime | |
|---|---|---|
| APIs | All Node.js APIs and npm packages | Web APIs only (fetch, Request, crypto.subtle) |
| Where it runs | Your server / serverless function in one region | Many locations close to users |
| Cold start | Slower | Very fast |
| Database drivers / Prisma | Yes | Only HTTP-based drivers |
| Typical use | Pages, actions, most route handlers | Simple redirects, geolocation, A/B, small APIs |
Choosing
// app/api/geo/route.ts
export const runtime = 'edge';
export function GET(req: Request) {
const country = req.headers.get('x-vercel-ip-country') ?? 'IN';
return Response.json({ country, currency: country === 'IN' ? 'INR' : 'USD' });
}Note: Edge is not automatically faster: if your database is in Mumbai, an edge function in Frankfurt still waits for Mumbai. Put compute close to your data. In Next.js 16 middleware (proxy.ts) runs on Node.js by default.