fix: give a clear error when Auth0Provider cannot read the root context - #12
Merged
Conversation
nandan-bhat
force-pushed
the
fix/SDK-10664-provider-root-safety
branch
from
August 7, 2026 09:53
ed4699a to
ce2383f
Compare
Piyush-85
approved these changes
Aug 7, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Auth0Providerread the router context with a hardcodeduseRouteContext({ from: '__root__' }). If an app named or structured its root route differently, TanStack Router threw an opaque invariant error instead of a message that points at the fix. This also documents that login and logout use a full browser navigation on purpose (SDK-10667).Fix
fromprop toAuth0ProviderProps(defaults to__root__), so an app can point the provider at its own root route id.useRouteContextcall so a missing or unknown route id throws a clear SDK error that names the likely cause (auth0BeforeLoad()not set) and thefromprop, instead of an opaque router error.useLoginanduseLogoutperform a full browser navigation (not a TanStack Router transition), because the/auth/*routes are handled on the server and the browser must reload to pick up the new session cookie. Added in the JSDoc and the README.Changes
src/client/provider.tsx: optionalfromprop, guarded context read, hard-nav JSDoc.README.md: note on the login/logout navigation behavior.src/client/provider.test.tsx: tests for the clear error on an unknown route id and for reading context from a customfromid.Test plan
npm run buildpassesnpm run lintpassesnpm run testpasses