Consenti
Showing:Frontend + BackendChange →

Quick Start — Frontend + Backend

The backend module records consent server-side and serves an admin dashboard. Profiles are managed through the UI — no code changes needed to update copy or buttons.

1. Install

bash
# On your backend (Node.js app)
npm install @consenti/api

# On your frontend (or same app for Next.js / Nuxt)
npm install @consenti/ui

2. Start the backend

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 dashboard → http://localhost:3001/consenti/
// REST API        → http://localhost:3001/consenti/api/v1/
ℹ️The default json driver works with zero installation. Switch to node:sqlite (Node 22.5+) or postgresql / mysql / mongodb before going to production. See API Configuration for all storage options.

Using Express?

app.ts
ts
import express from 'express'
import { createConsenti } from '@consenti/api'

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

3. Create a profile in the dashboard

Open http://localhost:3001/consenti/, log in, and create a profile for each compliance group your site needs. The backend automatically resolves the best profile per visitor via geo-routing.

4. Connect the frontend

main.ts
ts
import { ConsentiSetup } from '@consenti/ui'

const widget = new ConsentiSetup({
  api: {
    enabled: true,
    baseUrl: 'https://your-site.com', // where your backend is mounted
  },
  // compliance group resolved automatically per visitor via /resolve-profile
})

widget.onReady(() => {
  if (widget.isCookieGranted('analytics')) initAnalytics()
})
ℹ️If the API request fails (network error, server down), the widget automatically falls back to the matching pre-built profile — it never breaks the page.

What to read next