Clerk: auth() was called but clerkMiddleware() was not detected

Clerk says auth() was called but it can't detect clerkMiddleware()? The middleware file is missing, the matcher skipped the request, or a broken asset 404 ran the layout.

Reviewed October 15, 2026

What it means in plain English

A Clerk component asked who is signed in, and Clerk's middleware never ran for that request. The error Clerk prints is: auth() was called but Clerk can't detect usage of clerkMiddleware(). It then says the middleware or proxy file must use clerkMiddleware(), the matcher must cover the route, and a src app must keep that file inside src. On Next.js 15 and earlier, Clerk says the message talks about middleware only, not "middleware or proxy."

Likely causes

  • There is no middleware.ts (Next.js 15 or earlier) or proxy.ts (newer Next.js), or it sits outside src while the app is in src. Clerk's middleware reference says the filename is the only difference.
  • The matcher does not include the page that calls Clerk.
  • <ClerkProvider> is missing above the Clerk components.
  • An image or font src points at a file that does not exist. Clerk says the default matcher skips static assets, Next.js renders the 404 inside the root layout, and the provider then calls auth() without middleware.

How to fix it, step by step

  1. Add clerkMiddleware() in middleware.ts or proxy.ts at the project root, or inside src if the app lives there. Use the matcher from Clerk's middleware reference, including /__clerk/(.*).
  2. Wrap the app in <ClerkProvider> in the root layout, above any Clerk component. Clerk's error page shows that layout.
  3. If the provider is already there, open the network panel and look for a 404 on an image, icon, or other static file. Clerk says to correct that path. A 404 for a missing asset is the usual reason this appears after the middleware looks correct.
  4. Moving <ClerkProvider> into a route-group layout stops the 404 page from calling Clerk. Clerk says that avoids this error and does not fix the missing file.

How to check it worked

  • The Clerk error is gone from the server log and the browser console.
  • The network panel has no 404 for an image or font the layout requests.
  • Sign-in still renders.

Sources

More Clerk fixes

Keep going on your own.

The guides stay free. A deep leak report is $15. Fix packs are $24, or $49 for all three. There is no done-for-you repair.

See products