Consenti

SaaS Dashboard — Backend + SSO Admin

A B2B SaaS product with a compliance team that needs an audit trail and doesn't want engineers editing banner copy in code. The backend records every consent decision, and the admin dashboard is gated behind the company's existing Auth0 tenant — no separate Consenti password to manage.

What this demonstrates

  • node:sqlite storage — no external database to provision
  • OIDC (Auth0) admin login instead of local email/password
  • Frontend widget reporting consent to the backend, with automatic fallback on failure
  • Reading the saved record back from the consentSubmitted event

1. Backend

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

const consenti = createConsenti({
  storage: { driver: 'node:sqlite', path: './consenti-data' },
  auth: {
    mode: 'oidc',
    jwtSecret: process.env.CONSENTI_ADMIN_JWT_SECRET!,
    oidc: {
      issuer: 'https://your-tenant.auth0.com',
      clientId: process.env.AUTH0_CLIENT_ID!,
      clientSecret: process.env.AUTH0_CLIENT_SECRET!,
      redirectUri: 'https://app.example.com/consenti/admin/auth/oidc/callback',
      claimsMapping: {
        email: 'email',
        roles: 'consenti_roles', // custom claim in your Auth0 token
      },
    },
  },
  dashboard: true,
})

http.createServer(consenti.handler).listen(3001)
ℹ️Anyone in your Auth0 tenant can now sign in to /consenti/ with their existing company account. Map consenti_roles to Consenti's RBAC roles from the Roles section so, say, support staff only get read access to Consents.

2. Frontend widget

components/ConsentSetup.tsx
tsx
'use client'
import { useEffect } from 'react'
import { ConsentiSetup } from '@consenti/ui'

export function ConsentSetup() {
  useEffect(() => {
    const widget = new ConsentiSetup({
      api: { enabled: true, baseUrl: 'https://app.example.com' },
    })

    widget.on('consentSubmitted', ({ apiResponse, visitorId }) => {
      // apiResponse is the saved ConsentDbRecord — useful for support tooling
      console.log('Consent record', apiResponse.id, 'for visitor', visitorId)
    })

    return () => widget.destroy()
  }, [])
  return null
}

If Auth0 or the network is unreachable, the widget silently falls back to the matching pre-built profile — a SaaS outage never blocks the banner from rendering.

3. Audit trail, for free

Every profile edit an admin makes is versioned and viewable in Profile History; every admin action is written to the immutable Audit Log section. Nothing extra to configure — this ships with dashboard: true.