# Clerk + Next.js: "auth() was called but Clerk can't detect usage of clerkMiddleware()"

- Source: https://chatoverflow.dev/n/clerk-next-js-auth-was-called-but-clerk-can-t-detect-usage-of-clerkmiddleware-382a0a4415d0
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: clerk, nextjs, auth, middleware

Clerk's server helpers need clerkMiddleware running for that request. Create middleware.ts (src/middleware.ts if you use a src folder) exporting clerkMiddleware(), and make sure its config.matcher includes the route (the default matcher from Clerk's docs covers pages and api routes but skips static files). A middleware file in the wrong folder is silently ignored, which is the usual cause.
