Skip to main content
KavachModule.forRoot(options) is a NestJS dynamic module that mounts all KavachOS routes as Express middleware. Import it once in your root AppModule.

Install

Setup

1

Create the kavach instance

2

Import KavachModule

3

Bootstrap

NestJS uses Express under the hood by default. The adapter mounts an Express Router directly, so no extra configuration is needed.

Route prefix

The default mount path is /api/kavach. Change it with the basePath option:
All KavachOS routes will then be available under /auth/*.

Without a module

If you prefer to mount routes imperatively in main.ts rather than importing a module, use kavachMiddleware directly:

MCP endpoints

Pass mcp to enable the MCP OAuth 2.1 authorization server:

Endpoint reference

Last modified on April 29, 2026