fix(nextjs): add runtime error for auth() misimport from main entry point#8487
fix(nextjs): add runtime error for auth() misimport from main entry point#8487alexcarpenter wants to merge 2 commits intomainfrom
Conversation
…oint When developers import `auth` from `@clerk/nextjs` instead of `@clerk/nextjs/server`, the bundler shows a generic "'auth' is not exported" error with no guidance. Replace the type-only `declare const` stub with a real runtime Proxy export that throws a clear error message pointing to the correct import path. Ref: SDK-65 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
🦋 Changeset detectedLatest commit: 7e031ec The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
📝 WalkthroughWalkthroughReplaces the public Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
!snapshot |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@clerk/astro
@clerk/backend
@clerk/chrome-extension
@clerk/clerk-js
@clerk/dev-cli
@clerk/expo
@clerk/expo-passkeys
@clerk/express
@clerk/fastify
@clerk/hono
@clerk/localizations
@clerk/nextjs
@clerk/nuxt
@clerk/react
@clerk/react-router
@clerk/shared
@clerk/tanstack-react-start
@clerk/testing
@clerk/ui
@clerk/upgrade
@clerk/vue
commit: |
Summary
authfrom@clerk/nextjsinstead of@clerk/nextjs/server, the bundler previously showed a generic'auth' is not exported from '@clerk/nextjs'error with no hint about the correct import pathdeclare const auth: neverstub with a real runtime Proxy that throws a descriptive error:Clerk: auth() was imported from '@clerk/nextjs'. The auth() helper is a server-side function and must be imported from '@clerk/nextjs/server'.auth()) and property access (auth.protect), so the helpful error surfaces regardless of how the developer uses the misimported bindingRef: SDK-65
Test plan
auth-misimport.test.tscovering both function call and property access scenariosimport { auth } from '@clerk/nextjs'shows the new error instead of the bundler error🤖 Generated with Claude Code