The Edge runtime runs in a sandboxed environment without access to Node.js built-in modules like 'fs'. The native Fetch API, Web Crypto API, and URL parsing are supported in Edge runtime.
Edge runtime inlines all environment variables at build time, making them static. Node.js runtime can access all environment variables dynamically at runtime.
The correct way to specify Edge runtime is using runtime: 'edge'. Other strings like 'nodejs', 'server', or 'edge-runtime' are invalid and cause errors.
import crypto from 'crypto'; export const config = { runtime: 'edge' }; export default function handler() { const id = crypto.randomUUID(); return new Response(id); }
Node.js built-in modules like 'crypto' are not supported in Edge runtime. Importing them causes runtime errors because the environment does not provide these modules.
Edge runtime runs on lightweight, globally distributed serverless environments optimized for fast startup, resulting in lower cold start latency compared to Node.js runtime which uses traditional serverless functions with longer startup times.