Related Issue
The terminal displays the following warnings when building an application using Next v14.0.0, React v19.0.0, and the nextjs-auth0 v3.2.0 in a middleware:
./node_modules/next/dist/esm/shared/lib/router/utils/app-paths.js
A Node.js module is loaded ('url' at line 3) which is not supported in the Edge Runtime.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime
./node_modules/react/cjs/react.production.js
A Node.js API is used (process.emit at line: 172) which is not supported in the Edge Runtime.
Learn more: https://nextjs.org/docs/api-reference/edge-runtime
The terminal shows these warnings only when building the project for the first time.
Troubleshooting
These alerts are displayed because the Edge runtime doesn’t provide support for Node.js APIs.
The first warning has been fixed in a subsequent minor version release. It is recommended to upgrade Next to version 14.2.21.
The second alert appears due to the use of a Node.js API. The Auth0 middleware has a dependency on the next/navigation
module which in turn uses a Node.js API that is not supported by the Edge runtime. To resolve this issue, use React v19 alongside Next v15.
Next.js 15, App Router provides support for React 19 and is backward compatible with React 18 with Pages Router. Next.js 14, has React 18.2.0 as a peer dependency so it is recommended to use React 18 when using Next.js 14.
Possible solutions
Upgrade Next.js to v15 when using React v19.
When using Next.js v14, downgrade React to v18 and update Next.js to the latest v14 minor version (14.2.21).
Developer Resources for Auth0+Next.js
Check out the following resources if you’re interested in integrating Auth0 with Next.js.
- Next.js Authentication By Example: Using App Router (Next.js v14, React v18, Auth0 Next.js SDK v3)
- Next.js/TypeScript Pages Router Code Sample: Basic Authentication (Next.js v13, React v18, Auth0 Next.js SDK v3)
- Next.js/TypeScript App Router Code Sample (Next.js v15/React v19, Auth0 Next.js SDK v4 beta)