Repository navigation
0.1.0-alpha.7: server-rendered sessions, new guides, and a rewritten README - #8
Merged
Merged
Conversation
- Add `./tanstack-start` (`sessionHydration`, `loadSession`) and `./tanstack-start/server` (`startJar`) - Add the TanStack Start guide and the `tanstack-start-ssr` example - Let `Auth.layer` and `sessionBearer` take `createMirrorAuth` clients
- Add `./next` (`nextJar`, `proxyJar`) and `./next/client` (`useMirrorAuth`), with a guide and the `next-app` example - Check the `createServerAuth` secret on first use, so `next build` works without it - Add `next` 16 as an optional peer dependency
- Add `./react-router/server` (`cookieJarMiddleware`, `routerJar`) and `useMirrorAuth` in `./react-router`, with a guide and the `react-router-framework-ssr` example - Move the logic that keeps the mirror client in step with the server into a shared hook, used by `./next/client` too - Require React Router middleware: v8, or 7.9 or later with `future.v8_middleware`
…pters with
MirrorAuth
- prepare(jar, { skew }) is now refreshIfDue(jar, { within }); PrepareOptions is
RefreshIfDueOptions
- RequestContext (./react-router/server) is now RouterContextLike
- HydratedClient and ServerSessionClient are removed: sessionHydration,
loadSession and
both useMirrorAuth hooks take MirrorAuth<U>, and loadSession is generic
…rough the core client
…ze reused cookies from their save
- Requests holding the same expired cookie now reuse a failed backend refresh for ten seconds rather than each calling the backend again - A read-only `nextJar` reads through its store's writable jar, so it sees a sign-in made there - Document which calls reject on a read-only jar and with which code
… replacing next/client's and react-router's
…t the remaining copies, and fix a flaky tamper test
…e table of per-subpath settings
…n Effect and effetch section
…ffetch example app - Add TanStack Router and React Router guides; the README summarizes each adapter with excerpts the docs check keeps in sync - Add examples/tanstack-start-spa-effetch, built with Effect Schema, effetch and effetch-query, and restructure the README's Effect section to match - Add tree-shakeable, provenance and works-with badges to the README header
…es and common questions - List every client method, option and error code in tables, with a compiled example per topic - Add "Other HTTP clients", with axios interceptors and ky hooks built on auth.credentials; add axios and ky as dev dependencies so the examples compile - Add a "Common questions" section
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
This release adds sessions kept on the server for TanStack Start, Next.js 16 and React Router framework mode. The signed-in page renders on the first response, and the refresh token never reaches the browser. It also rewrites the README, adds guides for TanStack Router and React Router, and adds an example app built with Effect and effetch.
Server rendering
@monarcode/session-kit/server:createServerAuthkeeps both tokens and the user in an encryptedhttpOnlycookie (AES-256-GCM through Web Crypto, with rotatable secrets). It refreshes on the server and shares one refresh between parallel requests.createMirrorAuth: the browser client for that session. It starts from the session the server rendered, so there is noinitializingstate, and works with the hooks, the router guards,createAuthFetchandsessionBearer.sessionHydrationandloadSessionin./tanstack-start, andstartJar()in./tanstack-start/server.nextJarandproxyJarin./next.cookieJarMiddlewareandrouterJarin./react-router/server.useMirrorAuthin./react: one hook for every server-rendering framework. It creates the browser client and keeps it in step with the server.Each framework has a guide in
docs/and an example app.docs/server-sessions.mdcovers what the three share.Other additions
createAuthFetchtakesoptional: signed out, a request is sent withoutAuthorizationinstead of rejecting withUNAUTHENTICATED.examples/tanstack-start-spa-effetch: the TanStack Start SPA app written with Effect Schema, an effetch client withsessionBearer, one runtime, and effetch-query.Docs
docs/tanstack-router.md(including layouts around guarded pages and TanStack Start in SPA mode) anddocs/react-router.md(declarative, data and frameworkssr: falsemodes).auth.credentials.<!-- from: docs/guide.md -->must match the guide they come from, and guides can compile against the README's Getting started files.Breaking changes
@monarcode/effetchpeer range is now^0.1.0-rc.2, up fromrc.1.AuthFetchClientnow includesstate. AnycreateAuthclient still fits; a hand-written object needsstatetoo.Auth.layeraccepts acreateMirrorAuthclient, soAuthServiceClient'ssignInis optional.Auth.signIndies withINVALID_OPTIONSfor a client without one.Fixes
Auth.signInandAuth.updateUsercall the client's methods as methods, so a class-based client keeps itsthis.