# Next.js Edge Runtime build warning: Auth0 loads Node crypto via @auth0/nextjs-auth0 when used in middleware

**URL:** <https://community.auth0.com/t/next-js-edge-runtime-build-warning-auth0-loads-node-crypto-via-auth0-nextjs-auth0-when-used-in-middleware/196174>\
**Category:** Get Help\
**Tags:** sdks-quickstarts, nextjs-auth0\
**Created:** [January 12, 2026, 10:07am UTC](https://community.auth0.com/t/next-js-edge-runtime-build-warning-auth0-loads-node-crypto-via-auth0-nextjs-auth0-when-used-in-middleware/196174 "2026-01-12T10:07:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ReetamBG](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/reetambg/32/78042_2.png) [@ReetamBG](https://community.auth0.com/u/ReetamBG)\
**Post date:** [January 12, 2026, 10:07am UTC](https://community.auth0.com/t/next-js-edge-runtime-build-warning-auth0-loads-node-crypto-via-auth0-nextjs-auth0-when-used-in-middleware/196174/1 "2026-01-12T10:07:08Z")

</div>

I’m getting this warning during `next build`:

```bash
./node_modules/@auth0/nextjs-auth0/dist/utils/dpopUtils.js
A Node.js module is loaded ('crypto' at line 1) which is not supported in the Edge Runtime.
Learn More: https://nextjs.org/docs/messages/node-module-in-edge-runtime

Import trace for requested module:
./node_modules/@auth0/nextjs-auth0/dist/utils/dpopUtils.js
./node_modules/@auth0/nextjs-auth0/dist/server/client.js
./node_modules/@auth0/nextjs-auth0/dist/server/index.js
./lib/auth0.ts

```

Setup:

- `“next”: “15.3.8”`

- `“` @auth0`/nextjs-auth0”: “^4.14.0”`

My middleware.ts file:

```typescript
import type { NextRequest } from "next/server";

import { auth0 } from "./lib/auth0"; // Adjust path if your auth0 client is elsewhere

export async function middleware(request: NextRequest) {
  return await auth0.middleware(request);
}

export const config = {
  matcher: [
    /*
     * Match all request paths except for:
     * - _next/static (static files)
     * - _next/image (image optimization files)
     * - favicon.ico, sitemap.xml, robots.txt (metadata files)
     */
    "/((?!_next/static|_next/image|favicon.ico|sitemap.xml|robots.txt).*)"
  ]
};

```

This is the recommended pattern from the docs.  
But during build, my guess is Auth0 internally pulls in Node’s `crypto`, which Edge doesn’t support.

This started only after upgrading from Auth0 v3 to v4.  
v4 introduced using Auth0 in `middleware.ts`, which runs on the Edge Runtime.

Edge Runtime doesn’t support Node `crypto`, so Next warns — even though:

- `next dev` works

- `next build && next start` works

- App behavior is correct at runtime

So:

- Is `@auth0/nextjs-auth0` v4 actually Edge-safe?

- Or is this a known limitation where middleware works but still bundles Node-only code?

- Is there a recommended way to avoid this warning when using Auth0 in middleware?

---

<div class="post-metadata">

**Author:** ![nik.baleca](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/nik.baleca/32/68749_2.png) [@nik.baleca](https://community.auth0.com/u/nik.baleca)\
**Post date:** [January 12, 2026, 5:51pm UTC](https://community.auth0.com/t/next-js-edge-runtime-build-warning-auth0-loads-node-crypto-via-auth0-nextjs-auth0-when-used-in-middleware/196174/3 "2026-01-12T17:51:54Z")

</div>

Hi @ReetamBG

Welcome to the Auth0 Community!

I understand that you are looking for clarifications regarding the compatibility of `@auth0/nextjs-auth0` v4 with Microsoft Edge, any known limitations and recommendations.

### Official resolution

Allow me to share some information on each of the questions, which should provide more clarity and enable you to safely continue building.

**1. Is `@auth0/nextjs-auth0` v4 actually Edge-safe?**

**Yes** , NextJS v4 is compatible with [Edge Runtime](https://nextjs.org/docs/13/app/building-your-application/rendering/edge-and-nodejs-runtimes) and it is safe to run.

**2. Or is this a known limitation where middleware works but still bundles Node-only code?**

**This does not appear to be a reported, know limitation**. This issue is caused by a dependency chain where if Edge Runtime is being used, it ignores the standard Node `crypto` module and uses the standard [Web Crypto API](https://github.com/vercel/next.js/discussions/62985). The behaviour you have described above would be expected regarding the matter.

**3. Is there a recommended way to avoid this warning when using Auth0 in middleware?**

You can safely ignore this error or you can suppress the warning via NextConfig. It should look something like this:

```auto
import type { NextConfig } from "next";

const nextConfig: NextConfig = {
  webpack: (config, { isServer, nextRuntime }) => {
    // Only target the Edge runtime
    if (nextRuntime === 'edge') {
      config.resolve.fallback = {
        ...config.resolve.fallback,
        // Tell Webpack to replace 'crypto' with an empty object in the Edge bundle
        crypto: false, 
        stream: false, // Sometimes 'stream' is also flagged
      };
    }
    return config;
  },
};

export default nextConfig;

```

We hope the above information helped you overcome the ongoing issue. If you have any other questions, let me know!

Kind Regards,  
Nik

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/auth0/original/3X/b/5/b560f266932fcce5d57f09a6595bd50518cae3f3.jpeg) [@system](https://community.auth0.com/u/system)\
**Post date:** [January 26, 2026, 5:52pm UTC](https://community.auth0.com/t/next-js-edge-runtime-build-warning-auth0-loads-node-crypto-via-auth0-nextjs-auth0-when-used-in-middleware/196174/4 "2026-01-26T17:52:21Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
