Runtime-specific dependencies
What you need to know
Runtime compatibility is a property of the imported module graph, not just of the route file. A helper that looks portable can transitively import a Node-only package.
By the end, you can: audit module requirements; avoid assuming Node APIs at Edge.
Portable URL helper
// lib/catalog-url.tsexport function catalogPath(query:string){ const p=new URLSearchParams({q:query}); return '/catalog?'+p.toString();}console.log(catalogPath('river & fern'));Expected behavior: Prints /catalog?q=river+%26+fern. No filesystem dependency.
How it works
Audit direct and transitive imports, including conditional package exports, native addons and initialization code. An npm package that is written in JavaScript can still depend on filesystem access, Node streams or dynamic evaluation not available in a particular runtime. Keep portable functions in separate modules and place Node-specific adapters behind explicit server boundaries. The server-only marker guards accidental Client Component imports; it does not certify Edge compatibility. TypeScript declarations describe interfaces but do not establish that an implementation works in a host. For a real dependency, check documentation for the exact release, inspect its export conditions and build with the intended adapter. Avoid adding polyfills as a blanket fix: some operations, such as native filesystem access, have no equivalent in an isolated Edge host.
Audit a transitive import
app/api/edition/route.ts -> lib/public-edition.ts -> lib/read-local-file.ts -> node:fsAlternative: app/api/edition/route.ts -> lib/edition-data.ts (constant fixture)Expected behavior: The first graph depends on Node even if the Route Handler never imports node:fs directly. The second graph removes that specific dependency.
Common mistake
Do not move a Node-only import into a shared barrel file and expect an unused code path to be safe on all bundlers. Verify the actual resolved graph.
Practice and verification
Use the independent runtime classifier fixture to check Web-only, Node-required and unknown capability declarations. Then audit one actual pinned package before claiming adapter support.
Scope: Proposed Next.js 16.x / React 19, Cache Components disabled unless noted. Framework, browser and component examples are staged; local standalone tests are reported separately. Exact dependency patches and platform contracts pending.