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

What are the limitations of the Edge Runtime that might require you to use the Node.js Runtime instead?

Intermediate

Answer

The Edge Runtime does not support certain Node.js specific APIs, cannot use many npm packages that rely on native Node.js modules, has a smaller memory and execution time limit, and cannot directly connect to some traditional databases that expect a persistent Node.js style connection.
// This would fail in the Edge Runtime
// because it requires native Node.js file system access
import fs from 'fs';
Real-world example A route handler that needs to read and process large files from the server's file system must use the Node.js Runtime, since the Edge Runtime does not support this kind of file system access.

Common follow-ups: How do you know if a specific npm package works in the Edge Runtime?;What happens if you try to use an unsupported API in edge functions?