Skip to content

Webpack built Next Edge runtime not compatible with this library #2517

@PSoltes

Description

@PSoltes

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

  1. git clone https://github.com/energyaspects/nextjs-auth0-crypto-module-not-found
  2. npm install
  3. npm run dev
  4. GET /api/edge
  5. 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions