Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 469
feat(react-router): Add support for React Router v8#8972
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
82d31702325b4230f8c820a45795a318c5737441929d294bc3911b1447be7396afd33aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| --- | ||
| '@clerk/react-router': minor | ||
| --- | ||
| Add support for React Router v8. | ||
| If you're using React Router v7, keep the `v8_middleware` future flag enabled. If you're migrating to React Router v8, remove the flag: | ||
| ```diff | ||
| // react-router.config.ts | ||
| export default { | ||
| - future: { | ||
| - v8_middleware: true, | ||
| - }, | ||
| } | ||
| ``` |
MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. v7 smoke test to make sure our package is backwards compat |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,80 @@ | ||
| import { expect, test } from '@playwright/test'; | ||
| import type { Application } from '../../models/application'; | ||
| import { appConfigs } from '../../presets'; | ||
| import { createTestUtils } from '../../testUtils'; | ||
| const reactRouterV7PackageJson = `{ | ||
| "name": "clerk-react-router-quickstart", | ||
| "private": true, | ||
| "type": "module", | ||
| "scripts": { | ||
| "build": "react-router build", | ||
| "dev": "react-router dev --port $PORT", | ||
| "start": "NODE_ENV=production react-router-serve ./build/server/index.js", | ||
| "typecheck": "react-router typegen && tsc --build --noEmit" | ||
| }, | ||
| "dependencies": { | ||
| "@react-router/node": "^7.9.1", | ||
| "@react-router/serve": "^7.9.1", | ||
| "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", | ||
| "@types/node": "^20", | ||
| "@types/react": "^19.1.2", | ||
| "@types/react-dom": "^19.1.2", | ||
| "typescript": "^5.7.3", | ||
| "vite": "^7.1.5", | ||
| "vite-tsconfig-paths": "^5.1.4" | ||
| } | ||
| } | ||
| `; | ||
| const reactRouterV7Config = `import type { Config } from '@react-router/dev/config'; | ||
| export default { | ||
| ssr: true, | ||
| future: { | ||
| v8_middleware: true, | ||
| unstable_optimizeDeps: true, | ||
| }, | ||
| } satisfies Config; | ||
| `; | ||
| test.describe('React Router v7 compatibility @react-router', () => { | ||
| test.describe.configure({ mode: 'serial' }); | ||
| let app: Application; | ||
| test.beforeAll(async () => { | ||
| app = await appConfigs.reactRouter.reactRouterNode | ||
| .clone() | ||
| .addFile('package.json', () => reactRouterV7PackageJson) | ||
| .addFile('react-router.config.ts', () => reactRouterV7Config) | ||
| .commit(); | ||
| await app.setup(); | ||
| await app.withEnv(appConfigs.envs.withEmailCodes); | ||
| await app.dev(); | ||
| }); | ||
| test.afterAll(async () => { | ||
| await app?.teardown(); | ||
| }); | ||
| test('redirects unauthenticated protected route requests through v7 middleware context', async ({ | ||
| page, | ||
| context, | ||
| }) => { | ||
| const u = createTestUtils({ app, page, context }); | ||
| await u.page.goToRelative('/protected'); | ||
| await expect(u.page).toHaveURL(`${app.serverUrl}/sign-in`); | ||
| await u.po.signIn.waitForMounted(); | ||
| }); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Already talking to a react-router dev about this. There's an upstream issue in dev mode in v8 and to fix it, devs need to add
@clerk/react-routertossr.noExternal.This should be handled upstream in the following releases. If we got any report of it for v8 users, we can instruct the fix