Installation
Install Session kit and a schema library, then find the guide and example app for your setup.
Install Session kit, a schema library, and the packages your setup needs, then follow the guide for that setup.
To install the package, run the following command:
npm install @monarcode/session-kitAlpha releases are published to the latest distribution tag and may change
the public API, so 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. Compatibility lists every optional peer dependency and the versions it supports.
Pick your setup
Find your setup in the following table. Each one has an import path and a
guide. 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 |
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.
Next steps
- For a setup that keeps the session in the browser or on the device, start with Getting started. The router guides build on its app.
- For a server-rendered setup, start with Server rendering.