Skip to main content
The customSession plugin lets you store application-specific data inside every session without adding database columns. Fields live in session.metadata.custom.

Install

The plugin ships inside kavachos/auth, no extra packages needed.

Setup

Reading and writing fields

After setup, access the module through the plugin context:
updateSessionFields merges with existing data. Keys not in the update are left untouched.

Hook behaviour

onSessionCreate fires inside the plugin runner’s onSessionCreate hook, the same lifecycle point used by other plugins. The returned fields are merged into session.metadata.custom. If both defaultFields and the callback define the same key, the callback wins.

REST endpoints

GET example

PATCH example

Returns 404 when the session does not exist.

Config reference

Storage

No migrations required. Custom data is stored in the metadata JSON column of kavach_sessions under the custom key. Existing metadata keys (such as those written by other plugins) are not affected.
Last modified on April 18, 2026