Skip to content

Conversation

wobsoriano
Copy link
Member

@wobsoriano wobsoriano commented Sep 27, 2025

Description

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

  • New Features

    • React Router Node template now enables authentication middleware by default and streamlines server-side auth usage for a simpler setup.
  • Documentation

    • Updated minimum supported React Router version to ^7.9.0.
  • Refactor

    • Simplified loader pattern and consolidated server-side auth imports in templates for clarity and consistency.
  • Chores

    • Prepared a patch release for the React Router integration.
    • Added release metadata to track the documentation update.

Copy link

changeset-bot bot commented Sep 27, 2025

🦋 Changeset detected

Latest commit: 9765217

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

This PR includes changesets to release 1 package
Name Type
@clerk/react-router 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
Contributor

coderabbitai bot commented Sep 27, 2025

Walkthrough

Updates React Router template to use @clerk/react-router/server, activates Clerk middleware, simplifies the root loader, and refactors protected route to use clerkClient(args). README raises minimum react-router to ^7.9.0. Adds a changeset for a patch release of @clerk/react-router.

Changes

Cohort / File(s) Summary
Release and Docs
\.changeset/fifty-carrots-crash.md, packages/react-router/README.md
Add changeset for patch; update README React Router requirement from ^7.1.2 to ^7.9.0.
Template Root Setup
integration/templates/react-router-node/app/root.tsx
Switch imports to @clerk/react-router/server; export and enable middleware with clerkMiddleware(); simplify loader to direct rootAuthLoader(args) arrow function.
Protected Route Logic
integration/templates/react-router-node/app/routes/protected.tsx
Consolidate imports to server module; replace createClerkClient(...) with clerkClient(args); keep getAuth from server module; adjust user fetch accordingly.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor User
  participant Router
  participant Middleware as Clerk Middleware
  participant Loader as Root Loader (rootAuthLoader)
  participant Route as Protected Route Loader
  participant Clerk as clerkClient(args)

  User->>Router: HTTP request
  Router->>Middleware: Apply middleware
  Middleware-->>Router: Auth context attached
  Router->>Loader: loader(args)
  Loader-->>Router: auth data resolved
  Router->>Route: protected loader(args)
  Route->>Clerk: clerkClient(args).users.getUser(userId)
  Clerk-->>Route: User data
  Route-->>Router: Response payload
  Router-->>User: Rendered page
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

I twitch my whiskers, patch and hop,
Turn SSR to server—clean swap!
Middleware wakes, on guard we go,
clerkClient fetches users just so.
README nudged to nine-oh gate—
Thump! Templates aligned, we ship straight. 🥕🐇

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title clearly indicates that this chore relates to the React Router integration tests and succinctly describes the main action of enabling the new middleware; it is concise, specific, and aligned with the primary changes in the PR.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch rob/enable-rr-test

📜 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 d2968c1 and 9765217.

📒 Files selected for processing (2)
  • .changeset/fifty-carrots-crash.md (1 hunks)
  • packages/react-router/README.md (1 hunks)
✅ Files skipped from review due to trivial changes (2)
  • .changeset/fifty-carrots-crash.md
  • packages/react-router/README.md
⏰ 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). (28)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Static analysis
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

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

Copy link

vercel bot commented Sep 27, 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 Sep 27, 2025 5:24am

Copy link

pkg-pr-new bot commented Sep 27, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 9765217

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 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 5720787 and c8640e9.

📒 Files selected for processing (5)
  • .changeset/fifty-carrots-crash.md (1 hunks)
  • integration/templates/react-router-library/package.json (1 hunks)
  • integration/templates/react-router-node/app/root.tsx (1 hunks)
  • integration/templates/react-router-node/app/routes/protected.tsx (2 hunks)
  • integration/templates/react-router-node/package.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (9)
**/*.{js,jsx,ts,tsx}

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

**/*.{js,jsx,ts,tsx}: All code must pass ESLint checks with the project's configuration
Follow established naming conventions (PascalCase for components, camelCase for variables)
Maintain comprehensive JSDoc comments for public APIs
Use dynamic imports for optional features
All public APIs must be documented with JSDoc
Provide meaningful error messages to developers
Include error recovery suggestions where applicable
Log errors appropriately for debugging
Lazy load components and features when possible
Implement proper caching strategies
Use efficient data structures and algorithms
Profile and optimize critical paths
Validate all inputs and sanitize outputs
Implement proper logging with different levels

Files:

  • integration/templates/react-router-node/app/root.tsx
  • integration/templates/react-router-node/app/routes/protected.tsx
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

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

Use Prettier for consistent code formatting

Files:

  • integration/templates/react-router-node/app/root.tsx
  • integration/templates/react-router-node/package.json
  • integration/templates/react-router-library/package.json
  • integration/templates/react-router-node/app/routes/protected.tsx
**/*.{ts,tsx}

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

Use proper TypeScript error types

**/*.{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
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
Use protected for inheritance hierarchies
Use public explicitly for clarity in public APIs
Prefer readonly for properties that shouldn't change after construction
Prefer composition and interfaces over deep inheritance chains
Use mixins for shared behavior across unrelated classes
Implement dependency injection for loose coupling
Let TypeScript infer when types are obvious
Use const assertions for literal types: as const
Use satisfies operator for type checking without widening
Use mapped types for transforming object types
Use conditional types for type-level logic
Leverage template literal types for string manipulation
Use ES6 imports/exports consistently
Use default exports sparingly, prefer named exports
Use type-only imports: import type { ... } from ...
No any types without justification
Proper error handling with typed errors
Consistent use of readonly for immutable data
Proper generic constraints
No unused type parameters
Proper use of utility types instead of manual type construction
Type-only imports where possible
Proper tree-shaking friendly exports
No circular dependencies
Efficient type computations (avoid deep recursion)

Files:

  • integration/templates/react-router-node/app/root.tsx
  • integration/templates/react-router-node/app/routes/protected.tsx
**/*.{jsx,tsx}

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

**/*.{jsx,tsx}: Use error boundaries in React components
Minimize re-renders in React components

**/*.{jsx,tsx}: Always use functional components with hooks instead of class components
Follow PascalCase naming for components: 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
Use useState for simple state management
Use useReducer for complex state logic
Implement proper state initialization
Use proper state updates with callbacks
Implement proper state cleanup
Use Context API for theme/authentication
Implement proper state selectors
Use proper state normalization
Implement proper state persistence
Use React.memo for expensive components
Implement proper useCallback for handlers
Use proper useMemo for expensive computations
Implement proper virtualization for lists
Use proper code splitting with React.lazy
Implement proper cleanup in useEffect
Use proper refs for DOM access
Implement proper event listener cleanup
Use proper abort controllers for fetch
Implement proper subscription cleanup
Use proper HTML elements
Implement proper ARIA attributes
Use proper heading hierarchy
Implement proper form labels
Use proper button types
Implement proper focus management
Use proper keyboard shortcuts
Implement proper tab order
Use proper skip links
Implement proper focus traps
Implement proper error boundaries
Use proper error logging
Implement proper error recovery
Use proper error messages
Implement proper error fallbacks
Use proper form validation
Implement proper error states
Use proper error messages
Implement proper form submission
Use proper form reset
Use proper component naming
Implement proper file naming
Use proper prop naming
Implement proper...

Files:

  • integration/templates/react-router-node/app/root.tsx
  • integration/templates/react-router-node/app/routes/protected.tsx
integration/**

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

Framework integration templates and E2E tests should be placed under the integration/ directory

Files:

  • integration/templates/react-router-node/app/root.tsx
  • integration/templates/react-router-node/package.json
  • integration/templates/react-router-library/package.json
  • integration/templates/react-router-node/app/routes/protected.tsx
integration/**/*

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

End-to-end tests and integration templates must be located in the 'integration/' directory.

Files:

  • integration/templates/react-router-node/app/root.tsx
  • integration/templates/react-router-node/package.json
  • integration/templates/react-router-library/package.json
  • integration/templates/react-router-node/app/routes/protected.tsx
**/*.{js,ts,tsx,jsx}

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

Support multiple Clerk environment variables (CLERK_, NEXT_PUBLIC_CLERK_, etc.) for configuration.

Files:

  • integration/templates/react-router-node/app/root.tsx
  • integration/templates/react-router-node/app/routes/protected.tsx
**/*.tsx

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

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

Files:

  • integration/templates/react-router-node/app/root.tsx
  • integration/templates/react-router-node/app/routes/protected.tsx
.changeset/**

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

Automated releases must use Changesets.

Files:

  • .changeset/fifty-carrots-crash.md
🧬 Code graph analysis (2)
integration/templates/react-router-node/app/root.tsx (2)
packages/react-router/src/server/clerkMiddleware.ts (1)
  • clerkMiddleware (33-77)
packages/react-router/src/server/rootAuthLoader.ts (1)
  • rootAuthLoader (118-139)
integration/templates/react-router-node/app/routes/protected.tsx (1)
packages/react-router/src/server/clerkClient.ts (1)
  • clerkClient (5-21)
⏰ 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). (26)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Integration Tests (quickstart, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: semgrep-cloud-platform/scan

Comment on lines 12 to 21
"@react-router/node": "^7.9.3",
"@react-router/serve": "^7.9.3",
"isbot": "^5.1.17",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-router": "^7.9.1"
},
"devDependencies": {
"@react-router/dev": "^7.9.1",
"@react-router/dev": "^7.9.3",
"@types/node": "^20",
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Align the runtime react-router version.

We upgraded the toolchain packages to ^7.9.3, but the runtime dependency is still pinned to ^7.9.1. Mixing versions can surface incompatibilities (types, middleware support) in the generated template. Let's bump the runtime as well.

-    "react-router": "^7.9.1"
+    "react-router": "^7.9.3"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"@react-router/node": "^7.9.3",
"@react-router/serve": "^7.9.3",
"isbot": "^5.1.17",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-router": "^7.9.1"
},
"devDependencies": {
"@react-router/dev": "^7.9.1",
"@react-router/dev": "^7.9.3",
"@types/node": "^20",
"@react-router/node": "^7.9.3",
"@react-router/serve": "^7.9.3",
"isbot": "^5.1.17",
"react": "^19.1.0",
"react-dom": "^19.1.0",
"react-router": "^7.9.3"
},
"devDependencies": {
"@react-router/dev": "^7.9.3",
"@types/node": "^20",
🤖 Prompt for AI Agents
integration/templates/react-router-node/package.json lines 12-21: the runtime
dependency "react-router" is at ^7.9.1 while the dev/tooling packages were
updated to ^7.9.3; update the "react-router" entry to ^7.9.3 to match the rest
of the @react-router packages to avoid version mismatches, then run npm/yarn
install to update the lockfile.

@wobsoriano wobsoriano marked this pull request as draft September 27, 2025 01:09
@wobsoriano wobsoriano marked this pull request as ready for review September 27, 2025 04:31
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
integration/templates/react-router-library/package.json (1)

14-14: Reconsider pinning react-router to an exact patch

Dropping the caret prevents this template from receiving future 7.x bugfixes/security updates. Unless you’re working around a known regression, please keep the semver range or add a comment documenting why the lock is required to avoid silent staleness.

📜 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 c8640e9 and d2968c1.

📒 Files selected for processing (1)
  • integration/templates/react-router-library/package.json (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.{js,jsx,ts,tsx,json,css,scss,md,yaml,yml}

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

Use Prettier for consistent code formatting

Files:

  • integration/templates/react-router-library/package.json
integration/**

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

Framework integration templates and E2E tests should be placed under the integration/ directory

Files:

  • integration/templates/react-router-library/package.json
integration/**/*

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

End-to-end tests and integration templates must be located in the 'integration/' directory.

Files:

  • integration/templates/react-router-library/package.json
⏰ 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). (30)
  • GitHub Check: Integration Tests (ap-flows, chrome)
  • GitHub Check: Integration Tests (custom, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 14)
  • GitHub Check: Integration Tests (react-router, chrome)
  • GitHub Check: Integration Tests (machine, chrome)
  • GitHub Check: Integration Tests (billing, chrome)
  • GitHub Check: Integration Tests (nextjs, chrome, 15)
  • GitHub Check: Integration Tests (nuxt, chrome)
  • GitHub Check: Integration Tests (vue, chrome)
  • GitHub Check: Integration Tests (tanstack-react-router, chrome)
  • GitHub Check: Integration Tests (astro, chrome)
  • GitHub Check: Integration Tests (tanstack-react-start, chrome)
  • GitHub Check: Integration Tests (handshake:staging, chrome)
  • GitHub Check: Integration Tests (expo-web, chrome)
  • GitHub Check: Integration Tests (localhost, chrome)
  • GitHub Check: Integration Tests (handshake, chrome)
  • GitHub Check: Integration Tests (sessions, chrome)
  • GitHub Check: Integration Tests (elements, chrome)
  • GitHub Check: Integration Tests (express, chrome)
  • GitHub Check: Integration Tests (sessions:staging, chrome)
  • GitHub Check: Integration Tests (generic, chrome)
  • GitHub Check: Publish with pkg-pr-new
  • GitHub Check: Unit Tests (18, --filter=@clerk/astro --filter=@clerk/backend --filter=@clerk/express --filter=@c...
  • GitHub Check: Unit Tests (22, **)
  • GitHub Check: Static analysis
  • GitHub Check: Formatting | Dedupe | Changeset
  • GitHub Check: semgrep/ci
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: semgrep-cloud-platform/scan
  • GitHub Check: semgrep-cloud-platform/scan

@wobsoriano wobsoriano changed the title chore(repo): Use new middleware in React Router integration chore(react-router): Use new middleware in integration tests Sep 27, 2025
@wobsoriano wobsoriano merged commit ce119b2 into main Sep 27, 2025
45 checks passed
@wobsoriano wobsoriano deleted the rob/enable-rr-test branch September 27, 2025 10:13
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