Checklist
Description
Using Next 14 with edge runtime (export const runtime = 'edge') nextjs-auth0 lib throws an error about not being able to resolve crypto module - which makes sense, only subtle crypto is available in edge.
Suggested solution 1 - implement crypto "stuff" using subtle crypto as that is reliably available in Edge, Node and browser
Suggested solution 2 - do not load DPoP utils if they are not being used (for example we use edge runtime, but not DPoP)
Reproduction
- git clone https://github.com/energyaspects/nextjs-auth0-crypto-module-not-found
npm install
npm run dev
- GET
/api/edge
- Error is thrown
⨯ ./node_modules/@auth0/nextjs-auth0/dist/utils/dpopUtils.js:1:1
Module not found: Can't resolve 'crypto'
Additional context
Its likely happening due usage to webpack - same happens with Next 15 using webpack.
nextjs-auth0 version
4.14.1
Next.js version
14.2.35, also 15.5.11 when using webpack and not turbopack
Node.js version
22
Checklist
Description
Using Next 14 with edge runtime (
export const runtime = 'edge') nextjs-auth0 lib throws an error about not being able to resolvecryptomodule - which makes sense, only subtle crypto is available in edge.Suggested solution 1 - implement crypto "stuff" using subtle crypto as that is reliably available in Edge, Node and browser
Suggested solution 2 - do not load DPoP utils if they are not being used (for example we use edge runtime, but not DPoP)
Reproduction
npm installnpm run dev/api/edgeAdditional context
Its likely happening due usage to webpack - same happens with Next 15 using webpack.
nextjs-auth0 version
4.14.1
Next.js version
14.2.35, also 15.5.11 when using webpack and not turbopack
Node.js version
22