fix(template-generator): isolate tanstack start auth state - #1060
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughRefactors query client setup to a factory (createQueryClient), moves auth/dashboard under /_auth with backend-aware loaders and SSR toggles, makes Polar subscription checks null-safe, emits Cloudflare server Worker with url binding and wires frontend server-url envs, and updates CLI tests to validate these template outputs. ChangesQuery client factory, auth routing, Cloudflare infra, and tests
Possibly Related PRs
🚥 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 |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (1)
packages/template-generator/src/templates.generated.ts (1)
1376-1393: ⚡ Quick winAlign ORPC QueryClient
staleTimewith the tRPC variant (to avoid SSR hydration refetch).
packages/template-generator/src/templates.generated.ts(lines 1376-1393) shows the ORPCcreateQueryClient()createsnew QueryClient({ queryCache: ... })withoutdefaultOptions.queries.staleTime. In contrast, the tanstack-start tRPC factory setsdefaultOptions: { queries: { staleTime: 60 * 1000 } }inpackages/template-generator/templates/frontend/react/tanstack-start/src/router.tsx.hbs. Since both ORPC/tRPC usesetupRouterSsrQueryIntegration, ORPC’s queries are treated as immediately stale and can refetch on hydration. Add the samedefaultOptions.queries.staleTimeinpackages/template-generator/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs(or otherwise coordinate with the tanstack-start preload settings).
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: b287053d-a653-4870-8912-457a8501e3d5
📒 Files selected for processing (7)
apps/cli/test/api.test.tsapps/cli/test/deployment.test.tspackages/template-generator/src/templates.generated.tspackages/template-generator/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbspackages/template-generator/templates/auth/better-auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbspackages/template-generator/templates/frontend/react/tanstack-start/src/router.tsx.hbspackages/template-generator/templates/packages/infra/alchemy.run.ts.hbs
4154851 to
5a0a15b
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: ce15e36a-e566-49b4-8590-fad9ed654c66
📒 Files selected for processing (9)
apps/cli/test/api.test.tsapps/cli/test/auth.test.tsapps/cli/test/deployment.test.tspackages/template-generator/src/templates.generated.tspackages/template-generator/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbspackages/template-generator/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbspackages/template-generator/templates/auth/better-auth/web/react/tanstack-start/src/routes/dashboard.tsx.hbspackages/template-generator/templates/frontend/react/tanstack-start/src/router.tsx.hbspackages/template-generator/templates/packages/infra/alchemy.run.ts.hbs
🚧 Files skipped from review as they are similar to previous changes (6)
- packages/template-generator/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs
- apps/cli/test/api.test.ts
- packages/template-generator/templates/frontend/react/tanstack-start/src/router.tsx.hbs
- apps/cli/test/deployment.test.ts
- packages/template-generator/templates/packages/infra/alchemy.run.ts.hbs
- packages/template-generator/src/templates.generated.ts
5a0a15b to
904f30e
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
packages/template-generator/templates/auth/better-auth/web/react/tanstack-router/src/routes/_auth/dashboard.tsx.hbs (1)
31-32:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winRemove the subscription debug log.
customerState?.activeSubscriptionsis account/payment state, and thisconsole.logwill ship in every generated app.Suggested fix
const hasProSubscription = customerState?.activeSubscriptions?.length! > 0 - console.log("Active subscriptions:", customerState?.activeSubscriptions)
♻️ Duplicate comments (1)
apps/cli/test/auth.test.ts (1)
216-218:⚠️ Potential issue | 🟡 Minor | ⚡ Quick winAssert marker presence before comparing order.
Line 216-218 can pass when one marker is missing because
indexOf()may return-1. Add existence checks before the ordering assertion.Suggested fix
- expect(authRouteFile.indexOf("if (!session)")).toBeLessThan( - authRouteFile.indexOf("const customerState = await getPayment();"), - ); + const guardIndex = authRouteFile.indexOf("if (!session)"); + const paymentIndex = authRouteFile.indexOf( + "const customerState = await getPayment();", + ); + + expect(guardIndex).toBeGreaterThanOrEqual(0); + expect(paymentIndex).toBeGreaterThanOrEqual(0); + expect(guardIndex).toBeLessThan(paymentIndex);
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e3c2b8ca-3f64-47bb-8b88-5c7ba5a23e29
📒 Files selected for processing (27)
apps/cli/test/api.test.tsapps/cli/test/auth.test.tsapps/cli/test/clerk-matrix.test.tsapps/cli/test/deployment.test.tspackages/template-generator/src/templates.generated.tspackages/template-generator/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbspackages/template-generator/templates/api/trpc/web/react/base/src/utils/trpc.ts.hbspackages/template-generator/templates/auth/better-auth/convex/web/react/tanstack-router/src/routes/_auth/dashboard.tsx.hbspackages/template-generator/templates/auth/better-auth/convex/web/react/tanstack-router/src/routes/_auth/route.tsx.hbspackages/template-generator/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/_auth/dashboard.tsx.hbspackages/template-generator/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/_auth/route.tsx.hbspackages/template-generator/templates/auth/better-auth/web/react/tanstack-router/src/routes/_auth/dashboard.tsx.hbspackages/template-generator/templates/auth/better-auth/web/react/tanstack-router/src/routes/_auth/route.tsx.hbspackages/template-generator/templates/auth/better-auth/web/react/tanstack-start/src/routes/_auth/dashboard.tsx.hbspackages/template-generator/templates/auth/better-auth/web/react/tanstack-start/src/routes/_auth/route.tsx.hbspackages/template-generator/templates/auth/clerk/convex/web/react/tanstack-router/src/routes/_auth/dashboard.tsx.hbspackages/template-generator/templates/auth/clerk/convex/web/react/tanstack-router/src/routes/_auth/route.tsx.hbspackages/template-generator/templates/auth/clerk/convex/web/react/tanstack-router/src/routes/dashboard.tsx.hbspackages/template-generator/templates/auth/clerk/convex/web/react/tanstack-start/src/routes/_auth/dashboard.tsx.hbspackages/template-generator/templates/auth/clerk/convex/web/react/tanstack-start/src/routes/_auth/route.tsx.hbspackages/template-generator/templates/auth/clerk/convex/web/react/tanstack-start/src/routes/dashboard.tsx.hbspackages/template-generator/templates/auth/clerk/web/react/tanstack-router/src/routes/_auth/dashboard.tsx.hbspackages/template-generator/templates/auth/clerk/web/react/tanstack-router/src/routes/_auth/route.tsx.hbspackages/template-generator/templates/auth/clerk/web/react/tanstack-start/src/routes/_auth/dashboard.tsx.hbspackages/template-generator/templates/auth/clerk/web/react/tanstack-start/src/routes/_auth/route.tsx.hbspackages/template-generator/templates/frontend/react/tanstack-start/src/router.tsx.hbspackages/template-generator/templates/packages/infra/alchemy.run.ts.hbs
💤 Files with no reviewable changes (2)
- packages/template-generator/templates/auth/clerk/convex/web/react/tanstack-router/src/routes/dashboard.tsx.hbs
- packages/template-generator/templates/auth/clerk/convex/web/react/tanstack-start/src/routes/dashboard.tsx.hbs
✅ Files skipped from review due to trivial changes (4)
- packages/template-generator/templates/auth/better-auth/convex/web/react/tanstack-start/src/routes/_auth/route.tsx.hbs
- packages/template-generator/templates/auth/clerk/web/react/tanstack-start/src/routes/_auth/route.tsx.hbs
- packages/template-generator/templates/auth/clerk/convex/web/react/tanstack-start/src/routes/_auth/dashboard.tsx.hbs
- packages/template-generator/templates/api/orpc/web/react/base/src/utils/orpc.ts.hbs
🚧 Files skipped from review as they are similar to previous changes (4)
- apps/cli/test/api.test.ts
- apps/cli/test/deployment.test.ts
- packages/template-generator/templates/packages/infra/alchemy.run.ts.hbs
- packages/template-generator/templates/frontend/react/tanstack-start/src/router.tsx.hbs
904f30e to
a8dcaf2
Compare
a8dcaf2 to
2140494
Compare
2140494 to
258494c
Compare
258494c to
6c80944
Compare
Summary
_authlayouts while preserving the public/dashboardURL_authlayout for both TanStack Router and TanStack StartVerification
_authis pathless and/dashboardremains the public routeDocs checked
Summary by CodeRabbit
New Features
Bug Fixes
Tests