fix(clerk): upgrade add-on to @clerk/tanstack-react-start with server middleware#408
fix(clerk): upgrade add-on to @clerk/tanstack-react-start with server middleware#408Meet-08 wants to merge 1 commit intoTanStack:mainfrom
Conversation
Changes: - Replaced @clerk/clerk-react with @clerk/tanstack-react-start in package.json & info.json - Updated provider.tsx, header-user.tsx, and demo/clerk.tsx imports to new package - Replaced non-existent SignedIn/SignedOut components with <Show when='...'> in header-user.tsx - Added src/start.ts integrating clerkMiddleware() into createStart() - Registered CLERK_SECRET_KEY as required/secret in info.json and scaffolded .env.local
|
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (7)
📝 WalkthroughWalkthroughThis pull request migrates the Clerk authentication integration from Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
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 Tip You can disable sequence diagrams in the walkthrough.Disable the |
Problem
The Clerk add-on currently scaffolds
@clerk/clerk-react, a client-side-only SDK with no server exports. This makes it incompatible with TanStack Start's primary value proposition — server functions — since any call to Clerk auth on the server fails at runtime with a missing export error.Solution
Upgrade the add-on to
@clerk/tanstack-react-start, Clerk's official TanStack Start SDK, which provides both client-side components/hooks and server-side exports (auth(),clerkMiddleware()) from a single package. This brings the scaffolded output in line with Clerk's official TanStack Start quickstart.Changes
package.json/info.json@clerk/clerk-reactwith@clerk/tanstack-react-startin bothdependenciesandpackageAdditionsCLERK_SECRET_KEYtoenvVarswithsecret: true— required byclerkMiddleware()for backend token verificationAsset files (
provider.tsx,header-user.tsx,demo/clerk.tsx)@clerk/tanstack-react-start<SignedIn>/<SignedOut>with<Show when="signed-in">/<Show when="signed-out">, which is the correct control component API in the new SDKsrc/start.ts(new file)createStart()withclerkMiddleware()registered as request middleware, making auth context available to all server functions and enabling route-level protection_dot_env.local.appendCLERK_SECRET_KEY=to the generated.env.localtemplate alongside the existingVITE_CLERK_PUBLISHABLE_KEYNotes
@clerk/tanstack-react-startre-exports all client-side hooks and components, so there are no breaking changes for client-side usagecreateStartis imported from@tanstack/react-start, which is already a base dependency — no additional packages introducedtanstackStart()Vite plugin auto-discoverssrc/start.tsby convention; no changes tovite.config.tsare requiredSummary by CodeRabbit
New Features
Chores