Repository navigation
Release 0.1.0 alpha.4 - #5
Merged
Merged
Conversation
- Add a `storage` option and `AuthStorage` type, with `webStorage()` (`localStorage` default, or `sessionStorage` per tab) and `memoryStorage()` - Apply storage operations serially in issue order and re-check the session after each read, so late or out-of-order async storage cannot erase a newer sign-in - Add storage tests and a `test:async` run that defers every storage operation
credentials - Add `fromAccessToken`, `auth.refresh()` and a `revoke` callback with the `REVOKE_FAILED` error code, and make `AuthState` a discriminated union on `status` - Breaking: `userSchema` becomes `user`, `storage` is required, and `AuthClient` takes `<User, Input>`. `createRefreshFn` is removed, and `getSession()` returns no tokens, which move to `auth.credentials` (`get`, `renew`, `reject`) - Breaking: sessions are saved in a new format, so users sign in once after upgrading
…s from Router - Add `/tanstack-router` with `connectAuth`, `requireSession`, `SessionOutlet`, `redirectIfSignedIn` and `useRouterAuth`, and support React 18 - Breaking: `/react` exports only `createAuthHooks` (`useAuth`, `useAuthClient`, `AuthProvider`), `connectAuth` moves to `/tanstack-router`, and `safeReturnTo` moves to the package root - Breaking: make both peer dependencies optional and drop the `react-dom` peer
… on mount - Add `/react-router` with `SessionOutlet`, `requireSession`, `redirectIfSignedIn` and `useAuthRevalidation` for React Router 7 and 8, with `react-router` as an optional peer, and share guard logic with the TanStack Router entry point - Restore the saved session at mount when storage and the user source answer synchronously, and mount `AuthProvider` in a layout effect so `initializing` never paints
Start renders its SPA shell on the server at build time. connectAuth mounted the client there, found no storage, and published PERSISTENCE_FAILED, which could end up in the shell HTML and break hydration. - connectAuth returns a no-op disconnect when router.isServer is set, so the shell keeps the initializing state and renders the pending UI - webStorage() explains when localStorage or sessionStorage does not exist, pointing to defaultSsr: false in Start, instead of a bare TypeError - README: replace the "TanStack Start is not implemented" note; Start works in SPA mode with defaultSsr: false, React Router framework mode with ssr: false - Add CHANGELOG entries and tests for both behaviors
- Add five apps under `examples/` (TanStack Router, TanStack Start SPA, and React Router in declarative, data and framework `ssr: false` modes). They share `/login` and a protected `/` page, sign in against DummyJSON, and read the user from the login response or the access token - Turn the repo into a pnpm workspace over `examples/*`, add `build:examples` and a CI job that builds every app, and pass `--workspace-root` to the oldest-peers install. Bump the `@tanstack/react-router` dev dependency to 1.170.41 - Document the apps in the README, `examples/README.md` and the CHANGELOG, and ignore generated build output in `.gitignore`
- Replace the quick start with a TanStack Router walkthrough that signs in against DummyJSON, and link the matching example app for each other supported setup - Reorganize the reference into "Using the client" and "Schemas, refresh, and storage", with a peer dependency table, and drop the migration section - Update the version line to `0.1.0-alpha.4` and add a CHANGELOG entry
safeReturnTo turned "/.//evil.com" and "/%2e//evil.com" into "//evil.com". Check the parsed path, not the raw input. Bump to 0.1.0-alpha.4.
…d sign-ins - Stop cancelling a restore or refresh in progress on unmount, so a StrictMode remount joins it. This fixes expired sessions flashing `unavailable`, loaders rejecting with `SESSION_CHANGED`, and a rotated refresh token being sent twice - Track sign-in cancellation separately, so a failed `signIn` no longer aborts a restore or refresh, and only a newer `signIn` or `signOut()` cancels one still validating - Make route guards read the session again when `getSession()` rejects with `SESSION_CHANGED` - Move the deferred-storage test helpers into `tests/deferred-storage.ts`, and add regression tests for StrictMode, sign-in cancellation and guards
…rt basename In data and framework mode, SessionOutlet shows pending until the loader accepts a new account, so child routes never see the previous account's loader data. requireSession takes the router's basename and leaves it out of redirectTo. BREAKING CHANGE: @tanstack/react-router ^1.132.0 is required; earlier versions include the basepath in location.href.
…rces Storage reads, user validation, and token claims each have one implementation that finishes synchronously when every step does, so the synchronous restore can no longer drift from the asynchronous one. Claims that are not JSON now restore synchronously, async sources validate once, and a remount applies changes other tabs saved while unmounted.
…ation AuthClient requires both type arguments, so leaving out the input no longer drops updateUser silently. Guard, React, and outlet client shapes are picked from AuthClient. connectAuth and useAuthRevalidation share one version watcher, which no longer revalidates after unmount. Regroup the alpha.4 changelog and document sessionStorage in duplicated tabs.
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.
This branch is the 0.1.0-alpha.4 release, based on
0.1.0-alpha.3. It has three themes:/reacthooks no longer depend on TanStack Router.It includes breaking changes (listed below), and the [CHANGELOG](CHANGELOG.md) has the full notes.
Security
safeReturnTono longer returns paths whose dot segments resolve to another origin. Inputs like/.//evil.comand/%2e//evil.comused to become//evil.com, which browsers follow toevil.com. Apps on alpha.3 or earlier that redirect tosafeReturnTo's result should upgrade.What's new
Storage
storageoption andAuthStoragetype, withwebStorage()(localStorage, orsessionStorageper tab) andmemoryStorage().webStorage()explain when browser storage is missing, as on a server, instead of throwing a bareTypeError.Users and sessions
fromAccessToken(claims, map?), which reads the user from a JWT access token.auth.refresh()to force a refresh, and an optionalrevokecallback with the newREVOKE_FAILEDcode.AuthStatea discriminated union, so checkingstatusnarrowsuser.AuthProviderin a layout effect soinitializingnever paints.crypto.randomUUIDandstructuredClonerequirements, for React Native.React and routers
/tanstack-routerwithconnectAuth,requireSession,SessionOutlet,redirectIfSignedInanduseRouterAuth./react-routerfor React Router 7 and 8 in declarative, data and framework (ssr: false) modes, withuseAuthRevalidationand abasenameoption onrequireSession.connectAuthis a no-op while the Router renders on a server.Docs and examples
examples/, built in CI. The repo is now a pnpm workspace.Fixes
unavailable, reject waiting loaders and send the same refresh token twice, which signed users out when the backend rotates tokens.signInno longer cancels a restore or aborts a refresh. Only a newersignInorsignOut()cancels one still validating.SessionOutletno longer renders child routes with the previous account's loader data.getSession()rejects withSESSION_CHANGED.Breaking changes
createAuthtakesuserinstead ofuserSchema, andstorageis now required. Passstorage: webStorage()to keep the old behaviour.getSession()andretry()return{ sessionId, user }with no tokens.auth.credentials.get().refresh(session)becomescredentials.renew(credentials).rejectSession(session)becomescredentials.reject(credentials).auth.refresh()still exists but now takes no argument and forces a refresh.createRefreshFnis removed.AuthClientis nowAuthClient<User, Input>and needs both type arguments./reactexports onlycreateAuthHooks.connectAuthmoves to/tanstack-router, andsafeReturnTomoves to the package root.react-domis no longer one.@tanstack/react-routernow needs^1.132.0.updateUserand refresh reject withUSER_VALIDATION_FAILEDwhen the user schema does not accept its own output unchanged.Test plan
pnpm run checkpasses (lint, format, build, tests, type tests, README examples)pnpm testpasses in both the sync andtest:asyncstorage runspnpm run build:examplesbuilds the package and all five example apps@tanstack/react-router1.132.0,react-router7.0.0)