Consenti

Backend — Configuration

createConsenti(config) accepts a single configuration object. Every field is optional — calling it with an empty object is valid and gives you a running server immediately. This page covers the handful of options most deployments need.

Minimal config to get started

This is all you need. Copy it, set your password via an env var, and you have a working server with admin dashboard.

server.ts
ts
import { createConsenti } from '@consenti/api'
import http from 'node:http'

const consenti = createConsenti({
  storage: { driver: 'json', path: './consenti-data' },
  auth: {
    mode: 'local',
    adminEmail: '[email protected]',
    adminPassword: process.env.CONSENTI_ADMIN_PASSWORD!,
  },
  dashboard: true,
})

http.createServer(consenti.handler).listen(3001)
// Admin → http://localhost:3001/consenti/
// API   → http://localhost:3001/consenti/api/v1/
⚠️The json driver stores data in memory and flushes to disk. It is fine for development, but switch to SQLite or a server database before production. See storage in the advanced reference.

The options you'll change first

KeyDefaultWhat it does
storage.driver'json'Database engine — json for dev, SQLite/PostgreSQL/MySQL/MongoDB for production.
auth.mode'local'Admin dashboard authentication — local, jwt, oidc, saml, or custom.
dashboardfalseServe the built-in Preact admin SPA at basePath.
compliance.type'auto'Pin one of the 8 built-in compliance groups instead of geo-detecting — see the Jurisdiction Coverage Map for every country and its assigned group.
basePath'/consenti'URL prefix for all Consenti routes.
ℹ️This page covers the common cases. For every field — storage drivers, all five auth modes, rate limiting, S3 sync, plugins, TCF, age gate, data retention, and more — see the Advanced Configuration reference.