Installation
Install Session kit and a schema library, then find the guide and example app for your setup.
Your app needs Session kit, a schema library to describe your users, and the packages your setup already uses, such as React and your router. Install the first two here, then follow the guide for your setup.
To install Session kit, run the following command:
npm install @monarcode/session-kitRelease candidates are published to the latest distribution tag. The API
is frozen for 0.1: later 0.1 releases only add to it. Pin an exact version,
and read the
release notes
before upgrading.
Session kit checks each user against a schema from any Standard Schema library. The examples use Zod. To install it, run the following command:
npm install zodThen install React, and the router or framework your setup uses. Each is an optional peer dependency, so install only the ones your setup imports.
Session kit needs TypeScript 5.4 or newer, and Effect asks for 5.9 or newer. Compatibility lists the runtimes and the peer dependency versions it supports.
Pick your setup
Find your setup in the following table. Each row names the entry point for
your router or framework, and the guide to follow. All but the first also
have a runnable app in
examples/
that signs in against DummyJSON's public test API:
| Setup | Import | Guide | Example app |
|---|---|---|---|
| React without a router | @monarcode/session-kit/react | Getting started | None |
| TanStack Router | @monarcode/session-kit/tanstack-router | TanStack Router | tanstack-router |
| TanStack Start, SPA mode | @monarcode/session-kit/tanstack-router | TanStack Router | tanstack-start-spa, tanstack-start-spa-effetch |
| TanStack Start with server rendering | @monarcode/session-kit/tanstack-start | TanStack Start | tanstack-start-ssr |
| React Router, declarative mode | @monarcode/session-kit/react-router | React Router | react-router-declarative |
| React Router, data mode | @monarcode/session-kit/react-router | React Router | react-router-data |
React Router, framework mode, ssr: false | @monarcode/session-kit/react-router | React Router | react-router-framework-spa |
| React Router, framework mode with SSR | @monarcode/session-kit/react-router/server | React Router with SSR | react-router-framework-ssr |
| Next.js 16, App Router | @monarcode/session-kit/next | Next.js | next-app |
| Expo Router on iOS and Android, SDK 53+ | @monarcode/session-kit/expo | Expo Router | expo-router |
Every setup also imports its client from @monarcode/session-kit:
createAuth, or with server rendering, createMirrorAuth. Server-rendered
setups import more on the server, and each guide shows what.
Entry points lists every import path.
Two guides apply to more than one setup:
- Server sessions covers what the three server-rendered setups share.
- Effect and effetch works with any setup.
Docs for coding assistants
These docs are also available as plain Markdown, for AI coding assistants.
Point yours at /llms.txt, which links every page in reading
order, or at /llms-full.txt, which holds them all in one
file. For one page alone, add .md to its URL.
Next steps
- Getting started: start here for a setup that keeps the session in the browser. The web router guides build on its app.
- Expo Router: start here for an iOS or Android app. The guide starts from scratch.
- Server rendering: start here for TanStack Start, Next.js, or React Router with server rendering.