Back to results for “Deployment”
Next.js › Edge Runtime vs Node.js Runtime

What is the difference between the Edge Runtime and the Node.js Runtime in Next.js?

Beginner

Answer

The Node.js Runtime is the full Node.js environment with access to all Node.js APIs and packages, while the Edge Runtime is a lighter, faster environment that runs closer to your users around the world, but supports a smaller set of APIs and does not support every Node.js package.
// Choosing the runtime for a route handler
export const runtime = 'edge'; // or 'nodejs'
Real-world example A global news website uses the Edge Runtime for its middleware to check authentication quickly close to users everywhere, while using the Node.js Runtime for a route that processes complex image uploads requiring full Node.js library support.

Common follow-ups: Which Node.js features are not available in the Edge Runtime?;How do you decide which runtime is right for a specific route?