Skip to main content
@kavachos/svelte provides reactive Svelte stores and a SvelteKit hooks integration. It works with Svelte 4+, SvelteKit, and plain Vite setups.

Installation

Setup

Create a client instance and export the stores from a shared module:
src/lib/kavach.ts

SvelteKit setup

In SvelteKit, expose the session on the server side via hooks.server.ts so the initial page load is never unauthenticated:
src/hooks.server.ts
Access the session in +layout.server.ts:
src/routes/+layout.server.ts

Session store

src/routes/+page.svelte

Sign in / sign up / sign out

src/routes/sign-in/+page.svelte
Sign up
Sign out

createAgentStore

Manage agent identities in reactive Svelte stores:

Client configuration reference

string
default:"'/api/kavach'"
Base path where your KavachOS handler is mounted.
RequestInit
Options passed to every internal fetch call.
Last modified on April 29, 2026