Skip to content

Conversation

@LekoArts
Copy link
Contributor

@LekoArts LekoArts commented May 28, 2025

Description

React Router made an internal breaking change in 7.6.1: https://github.com/remix-run/react-router/blob/main/CHANGELOG.md#v761

@react-router/dev - Renamed internal react-router/route-module export to react-router/internal

We were relying on react-router/route-module to give type annotations for rootAuthLoader.

In this PR we're moving away from using unstable internal APIs and instead use the publicly available LoaderFunction/LoaderFunctionArgs for our rootAuthLoader() and getAuth() types.

Previously we were trying to get this type: https://github.com/remix-run/react-router/blob/c06ec85cf05e0ec5a3f399160ae3512206fac980/packages/react-router/lib/types/route-module-annotations.ts#L103-L136

But we can also use https://github.com/remix-run/react-router/blob/c06ec85cf05e0ec5a3f399160ae3512206fac980/packages/react-router/lib/router/utils.ts#L185-L209 because it's the same shape.

Fixes #6012

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:
@changeset-bot
Copy link

changeset-bot bot commented May 28, 2025

🦋 Changeset detected

Latest commit: 0aeaa5c

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

@vercel
Copy link

vercel bot commented May 28, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
clerk-js-sandbox ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 3, 2025 9:46am
@LekoArts LekoArts marked this pull request as ready for review June 2, 2025 12:17
@LekoArts
Copy link
Contributor Author

LekoArts commented Jun 2, 2025

!allow-major

@pkg-pr-new
Copy link

pkg-pr-new bot commented Jun 3, 2025

Open in StackBlitz

@clerk/agent-toolkit

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

@clerk/astro

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

@clerk/backend

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

@clerk/chrome-extension

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

@clerk/clerk-js

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

@clerk/dev-cli

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

@clerk/elements

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

@clerk/clerk-expo

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

@clerk/expo-passkeys

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

@clerk/express

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

@clerk/fastify

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

@clerk/localizations

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

@clerk/nextjs

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

@clerk/nuxt

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

@clerk/clerk-react

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

@clerk/react-router

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

@clerk/remix

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

@clerk/shared

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

@clerk/tanstack-react-start

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

@clerk/testing

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

@clerk/themes

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

@clerk/types

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

@clerk/upgrade

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

@clerk/vue

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

commit: 0aeaa5c

@LekoArts LekoArts changed the title fix(react-router)!: Update types to use new /internal subpath fix(react-router): Update types to use new /internal subpath Jun 3, 2025
@LekoArts LekoArts changed the title fix(react-router): Update types to use new /internal subpath fix(react-router): Simplify types for LoaderFunctionArgs Jun 3, 2025
// TODO: Remove "any" on loaderData type and use Route.ComponentProps from userland code
type ClerkProviderProps = ClerkReactRouterOptions & {
loaderData?: ReactRouterComponentProps['loaderData'];
loaderData?: any;
Copy link
Contributor Author

@LekoArts LekoArts Jun 3, 2025

Choose a reason for hiding this comment

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

This was already resolving to any previously, so we can remove the reliance on react-router/route-module here

@LekoArts LekoArts merged commit e0d6fbe into main Jun 4, 2025
44 checks passed
@LekoArts LekoArts deleted the lekoarts/eco-659-react-router-types-in-rootauthloader-callback-function-not branch June 4, 2025 07:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

4 participants