Next.js › Edge Runtime vs Node.js Runtime
What is the difference between the Edge Runtime and the Node.js Runtime in Next.js?
BeginnerAnswer
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.