Skip to content

chore(nextjs): Updated URL for auth cant detect usage of clerkMiddleware #6035

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 3, 2025

Conversation

royanger
Copy link
Member

Description

This PR goes hand in hand with Docs PR 2273

The @clerk/nextjs error "Clerk: auth() was called but Clerk can't detect usage of clerkMiddleware()" is confusing to customers, and it would be hard to cover explaining links to missing static assets and fixing that in in the error.

This borrows from Next.js. The Docs PR includes a entire page covering the error and how to solve the reasons it can occur. This PR changes the link in the error from the Quickstart to the new page.

Checklist

  • pnpm test runs as expected.
  • pnpm build runs as expected.
  • (If applicable) JSDoc comments have been added or updated for any package exports
  • (If applicable) Documentation has been updated

Type of change

  • 🐛 Bug fix
  • 🌟 New feature
  • 🔨 Breaking change
  • 📖 Refactoring / dependency upgrade / documentation
  • other:

Copy link

changeset-bot bot commented May 30, 2025

🦋 Changeset detected

Latest commit: b2d128a

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@clerk/nextjs Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link

vercel bot commented May 30, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2025 2:57am

Copy link

pkg-pr-new bot commented May 30, 2025

Open in StackBlitz

@clerk/agent-toolkit

npm i https://pkg.pr.new/@clerk/agent-toolkit@6035

@clerk/astro

npm i https://pkg.pr.new/@clerk/astro@6035

@clerk/backend

npm i https://pkg.pr.new/@clerk/backend@6035

@clerk/chrome-extension

npm i https://pkg.pr.new/@clerk/chrome-extension@6035

@clerk/clerk-js

npm i https://pkg.pr.new/@clerk/clerk-js@6035

@clerk/dev-cli

npm i https://pkg.pr.new/@clerk/dev-cli@6035

@clerk/elements

npm i https://pkg.pr.new/@clerk/elements@6035

@clerk/clerk-expo

npm i https://pkg.pr.new/@clerk/clerk-expo@6035

@clerk/expo-passkeys

npm i https://pkg.pr.new/@clerk/expo-passkeys@6035

@clerk/express

npm i https://pkg.pr.new/@clerk/express@6035

@clerk/fastify

npm i https://pkg.pr.new/@clerk/fastify@6035

@clerk/localizations

npm i https://pkg.pr.new/@clerk/localizations@6035

@clerk/nextjs

npm i https://pkg.pr.new/@clerk/nextjs@6035

@clerk/nuxt

npm i https://pkg.pr.new/@clerk/nuxt@6035

@clerk/clerk-react

npm i https://pkg.pr.new/@clerk/clerk-react@6035

@clerk/react-router

npm i https://pkg.pr.new/@clerk/react-router@6035

@clerk/remix

npm i https://pkg.pr.new/@clerk/remix@6035

@clerk/shared

npm i https://pkg.pr.new/@clerk/shared@6035

@clerk/tanstack-react-start

npm i https://pkg.pr.new/@clerk/tanstack-react-start@6035

@clerk/testing

npm i https://pkg.pr.new/@clerk/testing@6035

@clerk/themes

npm i https://pkg.pr.new/@clerk/themes@6035

@clerk/types

npm i https://pkg.pr.new/@clerk/types@6035

@clerk/upgrade

npm i https://pkg.pr.new/@clerk/upgrade@6035

@clerk/vue

npm i https://pkg.pr.new/@clerk/vue@6035

commit: b2d128a

@tmilewski tmilewski changed the title chore(nextjs): Updated URL for auth() can't detect usage of clerkMiddleware() error chore(nextjs): Updated URL for auth can't detect usage of clerkMiddleware May 30, 2025
@tmilewski tmilewski changed the title chore(nextjs): Updated URL for auth can't detect usage of clerkMiddleware chore(nextjs): Updated URL for auth cant detect usage of clerkMiddleware May 30, 2025
@royanger
Copy link
Member Author

Thanks for fixing the title/linting issue @tmilewski! Sorry I didn't get to it first.

I marked this blocked to make sure it doesn't get merged unless the Docs PR gets merged too. Appreciate the reviews Tom and @wobsoriano!

@jacekradko
Copy link
Member

Love the idea of pointing this error to a dedicated troubleshooting page—it's a DX win for users! I do have one long‑term concern, though, which is link durability: once we ship a hard‑coded URL in the package, any future re‑org of docs risks breaking it.

I think it would be worthwhile to add a simple shortcode/redirect layer (e.g., https://clerk.com/err/auth-middleware) that resolves to the current canonical doc?

Benefits:

  • Zero‑breakage moves – we can freely restructure docs without leaving old versions in place or touching package code.
  • Analytics & A/B tests – centralized redirects make it trivial to measure hit counts or experiment with different help surfaces.
  • Version targeting – shortcode could even branch based on SDK version or query param to surface the right docs

I think this would be very low hanging fruit but could give us a ton of flexibility and visibility into SDK error messages

@royanger
Copy link
Member Author

Love the idea of pointing this error to a dedicated troubleshooting page—it's a DX win for users! I do have one long‑term concern, though, which is link durability: once we ship a hard‑coded URL in the package, any future re‑org of docs risks breaking it.

I think this is a great idea! Thanks for making it. I'm going to share with the docs team. The clerk repo handles redirects, so that would be easy to setup.

I updated to https://clerk.com/err/auth-middleware in 20b173a

@royanger royanger self-assigned this Jun 3, 2025
@royanger royanger merged commit a5619ed into main Jun 3, 2025
36 checks passed
@royanger royanger deleted the roy/improve-middleware-error-messaging branch June 3, 2025 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants