Skip to content

chore(react-router): Remove deprecated pre-middleware setup#7796

Merged
wobsoriano merged 3 commits intomainfrom
rob/USER-4646-remove-deprecated-setup
Feb 7, 2026
Merged

chore(react-router): Remove deprecated pre-middleware setup#7796
wobsoriano merged 3 commits intomainfrom
rob/USER-4646-remove-deprecated-setup

Conversation

@wobsoriano
Copy link
Copy Markdown
Member

@wobsoriano wobsoriano commented Feb 7, 2026

Description

Removes support for the legacy pre-middleware setup in @clerk/react-router. Apps must now use clerkMiddleware() to integrate Clerk.

The middleware-based approach was introduced months ago and has been the recommended pattern since then. This change completes the migration by removing the legacy fallback path.

Resolves USER-4646

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

  • Refactor

    • Server-side authentication now requires middleware and no longer falls back to legacy paths; auth flow simplified.
    • Major version bump reflecting the new middleware-first behavior.
  • New Features / Public API

    • Added exported middleware for server integrations.
    • rootAuthLoader is now provided from the server package (updated import surface).
  • Chores

    • Removed legacy test suites and migration documentation.

@vercel
Copy link
Copy Markdown

vercel Bot commented Feb 7, 2026

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

Project Deployment Actions Updated (UTC)
clerk-js-sandbox Ready Ready Preview, Comment Feb 7, 2026 0:49am

Request Review

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Feb 7, 2026

🦋 Changeset detected

Latest commit: bc57b10

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 Major

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

@wobsoriano wobsoriano changed the title chore(react-router): Remove legacy setup functions chore(react-router): Remove deprecated pre-middleware setup Feb 7, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Feb 7, 2026

📝 Walkthrough

Walkthrough

This pull request removes the legacy pre-middleware authentication flow from the React Router package. It deletes the legacyAuthenticateRequest implementation and its integration test, strips migration guidance from error utilities, and updates server code (getAuth, rootAuthLoader) to require middleware-provided auth context and throw when it is absent. Tests were adjusted to remove legacy mocks and expectations. Public API and behavior were simplified: rootAuthLoader’s signature changed, clerkMiddleware was introduced/exported, and legacy fallback paths and header-wrapping response behavior were removed.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly describes the main change: removing the deprecated pre-middleware setup from React Router, which matches the primary objective of the PR.
Linked Issues check ✅ Passed The PR fully implements the requirement to remove legacy pre-middleware request authentication setup, deleting the legacyAuthenticateRequest function and all related legacy code paths.
Out of Scope Changes check ✅ Passed All changes are scoped to removing the legacy authentication setup: the PR deletes deprecated code paths, tests, and error utilities; updates rootAuthLoader to require middleware; and introduces a changeset for API migration guidance.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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

@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new Bot commented Feb 7, 2026

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/react

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

@clerk/react-router

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/ui

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

@clerk/upgrade

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

@clerk/vue

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

commit: bc57b10

@wobsoriano
Copy link
Copy Markdown
Member Author

!allow-major

Copy link
Copy Markdown
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: 1

🤖 Fix all issues with AI agents
In @.changeset/green-humans-yawn.md:
- Line 5: The breaking-change sentence in the changeset is inverted: update the
description text so it correctly states that using rootAuthLoader without
installing clerkMiddleware() will now throw a runtime error (i.e., the code
requires clerkMiddleware()), referencing the symbols rootAuthLoader and
clerkMiddleware() so readers know the affected API; replace the current "will
not throw a runtime error" phrasing with a clear "will throw a runtime error"
explanation and, optionally, add a brief migration note advising to install
clerkMiddleware() where rootAuthLoader is used.

'@clerk/react-router': major
---

Usage of `rootAuthLoader` without the `clerkMiddleware()` installed will not throw a runtime error.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

Critical: Fix inverted logic in breaking change description.

The statement says "will not throw a runtime error" but based on the PR objectives and AI summary, the code now requires clerkMiddleware() and throws when it is absent. This is the opposite of what's documented.

This is critical because users rely on changeset documentation to understand breaking changes during migration.

📝 Proposed fix
-Usage of `rootAuthLoader` without the `clerkMiddleware()` installed will not throw a runtime error.
+Usage of `rootAuthLoader` without the `clerkMiddleware()` installed will now throw a runtime error.
📝 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
Usage of `rootAuthLoader` without the `clerkMiddleware()` installed will not throw a runtime error.
Usage of `rootAuthLoader` without the `clerkMiddleware()` installed will now throw a runtime error.
🤖 Prompt for AI Agents
In @.changeset/green-humans-yawn.md at line 5, The breaking-change sentence in
the changeset is inverted: update the description text so it correctly states
that using rootAuthLoader without installing clerkMiddleware() will now throw a
runtime error (i.e., the code requires clerkMiddleware()), referencing the
symbols rootAuthLoader and clerkMiddleware() so readers know the affected API;
replace the current "will not throw a runtime error" phrasing with a clear "will
throw a runtime error" explanation and, optionally, add a brief migration note
advising to install clerkMiddleware() where rootAuthLoader is used.

@wobsoriano wobsoriano merged commit 833b325 into main Feb 7, 2026
66 of 68 checks passed
@wobsoriano wobsoriano deleted the rob/USER-4646-remove-deprecated-setup branch February 7, 2026 02:44
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.

2 participants