Skip to content

0.1.0-alpha.7: server-rendered sessions, new guides, and a rewritten README - #8

Merged
monarcode merged 35 commits into
mainfrom
0.1.0-alpha.7
Nov 10, 2026
Merged

monarcode merged 35 commits into
mainfrom
0.1.0-alpha.7

Conversation

@monarcode

@monarcode monarcode commented Nov 10, 2026 •

Copy link
Copy Markdown
Owner

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: createServerAuth keeps both tokens and the user in an encrypted httpOnly cookie (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 no initializing state, and works with the hooks, the router guards, createAuthFetch and sessionBearer.
  • TanStack Start: sessionHydration and loadSession in ./tanstack-start, and startJar() in ./tanstack-start/server.
  • Next.js 16, App Router: nextJar and proxyJar in ./next.
  • React Router framework mode: cookieJarMiddleware and routerJar in ./react-router/server.
  • useMirrorAuth in ./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.md covers what the three share.

Other additions

  • createAuthFetch takes optional: signed out, a request is sent without Authorization instead of rejecting with UNAUTHENTICATED.
  • examples/tanstack-start-spa-effetch: the TanStack Start SPA app written with Effect Schema, an effetch client with sessionBearer, one runtime, and effetch-query.

Docs

  • README rewrite. It now reads from the start: why the package exists, a one-file example, how it works, a "Getting started" that needs no router, a summary of each adapter, and an "Effect and effetch" section. The reference half lists every client method, option and error code in tables, with a compiled example per topic, and ends with "Common questions".
  • New guides: docs/tanstack-router.md (including layouts around guarded pages and TanStack Start in SPA mode) and docs/react-router.md (declarative, data and framework ssr: false modes).
  • Other HTTP clients: the README shows axios interceptors and ky hooks built on auth.credentials.
  • Header badges: tree-shakeable, provenance, and a "works with" row.
  • Docs check: README excerpts marked <!-- from: docs/guide.md --> must match the guide they come from, and guides can compile against the README's Getting started files.

Breaking changes

  • The @monarcode/effetch peer range is now ^0.1.0-rc.2, up from rc.1.
  • AuthFetchClient now includes state. Any createAuth client still fits; a hand-written object needs state too.
  • Auth.layer accepts a createMirrorAuth client, so AuthServiceClient's signIn is optional. Auth.signIn dies with INVALID_OPTIONS for a client without one.

Fixes

  • Auth.signIn and Auth.updateUser call the client's methods as methods, so a class-based client keeps its this.
  • The mirror client renews past a cached token that has expired.
  • The session cookie is capped at two chunks.
  • Refresh failures are shared across requests on the server, and Next's jars are paired.
  • React Router saves a refresh begun before the response, and refuses one after it.

- 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
- 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
…t the

remaining copies, and fix a flaky tamper test
…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
@monarcode monarcode changed the title 0.1.0-alpha.7 0.1.0-alpha.7: server-rendered sessions, new guides, and a rewritten README Nov 10, 2026
@monarcode
monarcode merged commit bf53c88 into main Nov 10, 2026
3 checks passed
@monarcode
monarcode deleted the 0.1.0-alpha.7 branch November 10, 2026 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant