Skip to content

Conversation

@Ephem
Copy link
Contributor

@Ephem Ephem commented Dec 11, 2025

Description

This PR improves two things in the TanStack Router test template.

  • Moves <ClerkProvider> down inside <html>
    • This fixes an issue where we were injecting a script before the framework scripts had run, resulting in trying to call $_TSR.C() when it was still undefined
  • Makes the sign-in route a catch-all
    • Signing in when running the app manually was not working, but tests were passing, turns out the tests were working because they were using the hidden password field, so they were never updating the url

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:

Summary by CodeRabbit

  • Chores
    • Reorganized authentication provider scope within the application's document structure
    • Updated sign-in route path configuration

✏️ Tip: You can customize this high-level summary in your review settings.

@Ephem Ephem requested a review from wobsoriano December 11, 2025 17:50
@changeset-bot
Copy link

changeset-bot bot commented Dec 11, 2025

⚠️ No Changeset found

Latest commit: dcd20ad

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@vercel
Copy link

vercel bot commented Dec 11, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
clerk-js-sandbox Ready Ready Preview Comment Dec 11, 2025 5:50pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 11, 2025

Walkthrough

Two files in the TanStack React Start template were modified: the root layout moved ClerkProvider from wrapping the entire document structure to wrapping only children content, and the sign-in route path was updated from /sign-in to /sign-in/$.

Changes

Cohort / File(s) Summary
Provider scope adjustment
integration/templates/tanstack-react-start/src/routes/__root.tsx
Moved ClerkProvider wrapping scope from encompassing the entire document (html, head, body) to wrapping only {children}; html, head, and body elements now render outside ClerkProvider, with TanStackRouterDevtools and Scripts positioned inside body after ClerkProvider
Route path configuration
integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
Updated exported Route path parameter in createFileRoute from /sign-in to /sign-in/$

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Verify that authentication-dependent functionality remains unaffected with ClerkProvider scope moved inward
  • Confirm route path change /sign-in/$ aligns with intended routing behavior in TanStack Router

Poem

🐰 A hop and a route, a provider pulled tight,
From root to the children, we nested it right,
The sign-in path dances with a dollar sign's gleam,
Small changes, big blessings—the perfect React dream! ✨

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title uses 'test(e2e)' but the changes are code organization/structural fixes to a test template, not new tests; description reveals the primary changes are moving ClerkProvider positioning and making sign-in route catch-all to fix test failures. Consider a more descriptive title like 'fix(tanstack-start): Adjust ClerkProvider positioning and sign-in route in test template' to better reflect the structural fixes being made.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fredrik/fix-tanstack-start-tests

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Disabled knowledge base sources:

  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between d4cd794 and dcd20ad.

📒 Files selected for processing (2)
  • integration/templates/tanstack-react-start/src/routes/__root.tsx (1 hunks)
  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx (1 hunks)
🧰 Additional context used
📓 Path-based instructions (10)
**/*.{js,jsx,ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

All code must pass ESLint checks with the project's configuration

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
**/*.{js,jsx,ts,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use Prettier for consistent code formatting

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Follow established naming conventions (PascalCase for components, camelCase for variables)

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
**/*.ts?(x)

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Use proper TypeScript error types

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

**/*.tsx: Use error boundaries in React components
Minimize re-renders in React components

**/*.tsx: Use proper type definitions for props and state in React components
Leverage TypeScript's type inference where possible in React components
Use proper event types for handlers in React components
Implement proper generic types for reusable React components
Use proper type guards for conditional rendering in React components

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
**/*.{md,tsx}

📄 CodeRabbit inference engine (.cursor/rules/development.mdc)

Update documentation for API changes

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
**/*.{jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/react.mdc)

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components (e.g., UserProfile, NavigationMenu)
Keep components focused on a single responsibility - split large components
Limit component size to 150-200 lines; extract logic into custom hooks
Use composition over inheritance - prefer smaller, composable components
Export components as named exports for better tree-shaking
One component per file with matching filename and component name
Separate UI components from business logic components
Use useState for simple state management in React components
Use useReducer for complex state logic in React components
Implement proper state initialization in React components
Use proper state updates with callbacks in React components
Implement proper state cleanup in React components
Use Context API for theme/authentication state management
Implement proper state persistence in React applications
Use React.memo for expensive components
Implement proper useCallback for handlers in React components
Use proper useMemo for expensive computations in React components
Implement proper virtualization for lists in React components
Use proper code splitting with React.lazy in React applications
Implement proper cleanup in useEffect hooks
Use proper refs for DOM access in React components
Implement proper event listener cleanup in React components
Use proper abort controllers for fetch in React components
Implement proper subscription cleanup in React components
Use proper HTML elements for semantic HTML in React components
Implement proper ARIA attributes for accessibility in React components
Use proper heading hierarchy in React components
Implement proper form labels in React components
Use proper button types in React components
Implement proper focus management for keyboard navigation in React components
Use proper keyboard shortcuts in React components
Implement proper tab order in React components
Use proper ...

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/typescript.mdc)

**/*.{ts,tsx}: Always define explicit return types for functions, especially public APIs
Use proper type annotations for variables and parameters where inference isn't clear
Avoid any type - prefer unknown when type is uncertain, then narrow with type guards
Implement type guards for unknown types using the pattern function isType(value: unknown): value is Type
Use interface for object shapes that might be extended
Use type for unions, primitives, and computed types
Prefer readonly properties for immutable data structures
Use private for internal implementation details in classes
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Use mixins for shared behavior across unrelated classes in TypeScript
Use generic constraints with bounded type parameters like <T extends { id: string }>
Use utility types like Omit, Partial, and Pick for data transformation instead of manual type construction
Use discriminated unions instead of boolean flags for state management and API responses
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation at the type level
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Document functions with JSDoc comments including @param, @returns, @throws, and @example tags
Create custom error classes that extend Error for specific error types
Use the Result pattern for error handling instead of throwing exceptions
Use optional chaining (?.) and nullish coalescing (??) operators for safe property access
Let TypeScript infer obvious types to reduce verbosity
Use const assertions with as const for literal types
Use satisfies operator for type checking without widening types
Declare readonly arrays and objects for immutable data structures
Use spread operator and array spread for immutable updates instead of mutations
Use lazy loading for large types...

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
**/*.{js,ts,jsx,tsx}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use ESLint with custom configurations tailored for different package types

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
**/*.{js,ts,jsx,tsx,json,md,yml,yaml}

📄 CodeRabbit inference engine (.cursor/rules/monorepo.mdc)

Use Prettier for code formatting across all packages

Files:

  • integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx
  • integration/templates/tanstack-react-start/src/routes/__root.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (27)
  • GitHub Check: Integration Tests (nextjs, chrome, 16)
  • GitHub Check: Integration Tests (quickstart, chrome, 15)
  • GitHub Check: Integration Tests (quickstart, chrome, 16)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 16, RQ)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (machine, chrome, RQ)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (billing, chrome, RQ)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Build Packages
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
🔇 Additional comments (2)
integration/templates/tanstack-react-start/src/routes/sign-in.$.tsx (1)

4-6: Route path now correctly reflects the sign-in.$ catch-all intent

Updating the file route to /sign-in/$ matches the file name and should allow the sign‑in page to handle nested/catch‑all paths as intended. This looks consistent with TanStack Router’s file‑route conventions and the PR’s goal of aligning tests with manual sign‑in behavior.

Please double‑check that:

  • Direct navigation to /sign-in still resolves as expected, and
  • Any flows that append extra path segments under /sign-in/... are now correctly handled by this route.
integration/templates/tanstack-react-start/src/routes/__root.tsx (1)

23-44: ClerkProvider placement and document structure look correct

Having <html>, <head>, and <body> outside ClerkProvider, with ClerkProvider wrapping only {children} inside the body, is a good adjustment. It should avoid provider‑injected scripts running before the TanStack Router runtime while keeping HeadContent, TanStackRouterDevtools, and Scripts in the expected places.

Please verify in a real build (not only tests) that:

  • The original $_TSR.C() / “C undefined” issue no longer occurs during initial load and navigation, and
  • Clerk’s widgets still initialize correctly on both first render and client transitions.

Comment @coderabbitai help to get the list of available commands and usage tips.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Dec 11, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

npm i https://pkg.pr.new/@clerk/ui@7440

@clerk/upgrade

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

@clerk/vue

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

commit: dcd20ad

Copy link
Member

@wobsoriano wobsoriano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch!

@Ephem Ephem merged commit cfd0cba into main Dec 12, 2025
154 of 164 checks passed
@Ephem Ephem deleted the fredrik/fix-tanstack-start-tests branch December 12, 2025 08:58
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.

3 participants