Configuration

Complete reference for all Kavach configuration options.

Configuration File

Create a kavach.config.js file in your project root:

export default {
  adapter: 'supabase',
  providers: [
    { name: 'google', label: 'Google' },
    { name: 'magic', mode: 'otp', label: 'Magic Link' },
    { name: 'email', mode: 'password', label: 'Email' }
  ],
  routes: {
    auth: '(public)/auth',
    data: '(server)/data',
    rpc: '(server)/rpc',
    logout: '/logout'
  },
  rules: [
    { path: '/', public: true },
    { path: '/about', public: true },
    { path: '/dashboard', protected: true },
    { path: '/admin', roles: ['admin'] },
    { path: '/api', roles: ['user', 'admin'] }
  ],
  roleHome: {
    admin: '/admin',
    user: '/dashboard'
  },
  logging: {
    level: 'info',
    table: 'audit_logs'
  }
}

Environment Variables

Add to your .env file:

# .env
PUBLIC_SUPABASE_URL=https://your-project.supabase.co
PUBLIC_SUPABASE_ANON_KEY=your-anon-key

Configuration Options

adapter

Auth provider: supabase, firebase, auth0, amplify, convex

providers

Authentication methods to enable. Each has name, optional mode, and label.

routes

Path configuration for auth flows: auth, logout, data (optional), rpc (optional).

rules

Route protection rules. Each rule has path, and either public: true, protected: true, or roles.

roleHome

Map of roles to redirect targets after login.

logging

Logging configuration: level (error/warn/info/debug/trace) and optional table name.

Next Steps

Kavach — Authentication made simple llms.txt