Capítulo 283 de 456
Next.js has two server runtimes: the default Node.js runtime with full Node API access, and the Edge Runtime, a restricted Web-standard-APIs-only runtime used in Proxy (and legacy edge routes).
require is disallowed, must use ES Modules.unstable_allowDynamic: Proxy config glob (or array of globs) that whitelists files containing unreachable dynamic code evaluation statements, so Turbopack/webpack don't flag them.import.meta.env/Node polyfills: process.env works for both next dev/next build; AsyncLocalStorage is a supported Next.js-specific polyfill.export const config = {
unstable_allowDynamic: [
'/lib/utilities.js',
'**/node_modules/function-bind/**',
],
}
| API category | Supported examples |
|---|---|
| Network | fetch, Request, Response, Headers, FormData, Blob, File, WebSocket, FetchEvent |
| Encoding | atob, btoa, TextEncoder/TextDecoder (+ Stream variants) |
| Streams | ReadableStream, WritableStream, TransformStream and their readers/writers |
| Crypto | crypto, CryptoKey, SubtleCrypto |
| Web Standard | URL, URLPattern, URLSearchParams, Intl, typed arrays, JSON, Promise, structuredClone, standard error types, etc. |
| Next.js polyfill | AsyncLocalStorage |
| Unsupported/disabled | Note |
|---|---|
| Native Node.js APIs | No filesystem access, etc. |
require() | Use ES Modules instead |
eval, new Function(evalString) | Disabled |
WebAssembly.compile / .instantiate | Disabled |
unstable_allowDynamic, understanding execution still throws.node_modules packages that rely on native Node APIs: only ESM packages without native Node dependencies work on Edge.require to fail.unstable_allowDynamic only suppresses the build-time warning for unreachable dynamic code; it does not make dynamic eval safe to actually execute on Edge.edgeRuntime invocation metadata.