Skip to content

Repository files navigation

Kavach

Focus on what truly matters: crafting exceptional applications. Kavach provides a set of components and utility functions that effortlessly integrate authentication and role-based route protection into your app, without compromising its performance or flexibility.

Maintainability Test Coverage GitHub Workflow Status GitHub last commit

kavach

What

Kavach is a drop-in authentication framework for SvelteKit. It provides:

  • A unified API across multiple auth platforms
  • Declarative route protection
  • Pre-built UI components

So you can add secure authentication to your app in minutes, not days.

Why

  • Platform-agnostic — Switch between Supabase, Firebase, Auth0, Amplify, or Convex by swapping one adapter
  • Declarative route protection — Define rules once; no scattered if (!user) checks
  • Type-safe — Full TypeScript support with centralized types
  • Server + Client — Unified session management across browser and server

Quick Start

# Create a SvelteKit project
sv create my-app
cd my-app

# Follow the guided prompts to add Kavach to your project
bunx @kavach/cli init
bun run dev

Supported Adapters

Provider Adapter Package Capabilities Status
Supabase @kavach/adapter-supabase Auth, Data, Storage, Logging
Firebase @kavach/adapter-firebase Auth
Auth0 @kavach/adapter-auth0 Auth
AWS Amplify @kavach/adapter-amplify Auth
Convex @kavach/adapter-convex Auth

To Do

  • Data, Storage & Logging to convex and Firebase
  • External storage providers
  • External logger api
  • External data api
  • Mix and match Auth, Data, Storage & Logging (ex Amplify + S3 + Custom Backend)

Packages

Core

  • kavach — Core auth: session management, credential flows, SvelteKit hooks
  • @kavach/sentry — Role-based route protection (RBAC)

CLI & Vite

  • @kavach/cli — CLI for scaffolding Kavach into SvelteKit projects
  • @kavach/vite — Vite plugin for code generation

Utilities

UI

  • @kavach/ui — Pre-built auth components, cached logins, smart layout

Adapters

Route Configuration

Routes are protected by default. Configure public routes in kavach.config.js:

export default {
  routes: {
    public: ['/login', '/register'],
    roles: {
      admin: { home: '/admin' },
      user: { home: '/dashboard' }
    }
  }
}

Learn More

License

MIT © Jerry Thomas

About

Drop in authentication including route protection and redirects.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages