Skip to content
The xtandard-audit logoThe xtandard-audit logo

Audit logs your customers can verify

A self-hosted, embeddable, tamper-evident audit-log control plane for B2B SaaS. Record typed events from your app into the database you already run, and give every customer a log of their organization they can browse, export and verify, with no per-event pricing and no separate service to operate.
Terminal window
npm install @xtandard/audit

A WorkOS Audit Logs alternative as a library. record() is one call in your request handler. Every tenant gets its own hash chain with signed checkpoints, so your customers, and their auditors, can verify that nobody, including you, altered or deleted their history.

Typed events

Declare your action catalog once with any Standard Schema validator (valibot, zod, arktype): record() autocompletes actions, and wrong metadata is a compile error and a runtime error.

Tamper evidence

A hash chain per tenant, sectioned digests so personal data can be erased without breaking it, and Ed25519-signed checkpoints that a zero-dependency verifier checks offline.

A customer portal

Your customers browse, filter, export and verify their own events inside your product, scoped by a signed token: no sessions, no proxy routes.

Exports & SIEM streaming

CSV, JSON and a verifiable bundle; at-least-once, per-tenant ordered streams to HTTP, Standard Webhooks, Datadog, Splunk, S3 or files. Nothing sits on the record path.

Your storage

Postgres, SQLite, libSQL, Drizzle, MongoDB, Redis, unstorage, Cloudflare KV, files or memory: a four-method KV contract plus an optional native event log for indexed queries.

Framework adapters

Mount the admin UI and API in Hono, Elysia (1 and 2), Express or Bun, and fill tenant, actor, IP and request id for every event with one auditContext() middleware.

import { createAuditCore } from "@xtandard/audit";
import { createPostgresStorage } from "@xtandard/audit/storage/postgres";
const audit = createAuditCore({
storage: createPostgresStorage({ url: process.env.DATABASE_URL! }),
});
// In the handler where the thing actually happens:
await audit.record({
tenant: org.id, // the customer organization
action: "member.role_changed",
actor: { id: user.id, name: user.name, email: user.email },
targets: [{ type: "user", id: member.id, name: member.name }],
metadata: { from: "member", to: "admin" },
});

Synchronous-commit: record() validates, chains and appends, and throws rather than silently dropping. A buffered createRecorder() covers fire-and-forget hot paths. Quickstart →

flowchart LR
  subgraph host["your app process"]
    direction TB
    APP["app code"] -- "record()" --> CORE["<b>core</b><br/>validate · transform<br/>hash-chain · append"]
    PANEL["<b>panel</b><br/>admin UI + API + portal<br/>Hono · Elysia · Express · Bun"] --> CORE
    STREAMS["<b>stream runner</b><br/>per-tenant cursors<br/>batches · backoff"] --> CORE
  end
  CORE <--> DB[("your database<br/>Postgres · SQLite · Mongo<br/>Redis · Drizzle · KV …")]
  STREAMS -- "batches + signed checkpoints" --> SIEM["Datadog · Splunk · S3<br/>webhooks · HTTP"]
  PORTAL["&lt;AuditPortal&gt;<br/>in your product"] -- "portal token" --> PANEL
  AUDITOR["customer / auditor"] -- "verify bundle" --> VERIFY["/verify<br/>zero dependencies"]

The record plane (record()) is the hot path; the control plane (query, export, verify, checkpoints, retention, erasure) is hook-guarded, authorized and self-audited: exports and erasures land in the tenant’s own log. Architecture →

@xtandard/audit is one of a family of open-source, MIT-licensed projects that share the xtandard name. They are independent of each other: use any of them on its own. The products share their building blocks through @xtandard/kit, a regular dependency you never install or configure yourself.

Project What it is Links
@xtandard/audit (this package) A self-hosted, embeddable, tamper-evident audit-log control plane for B2B SaaS: a WorkOS Audit Logs alternative as a library Docs · GitHub · npm
@xtandard/kit The shared building blocks of the xtandard products: storage drivers and conformance suite, auth, HTTP plumbing, adapters, admin shell and tooling Docs · GitHub · npm
@xtandard/lib Lightweight, type-safe TypeScript utilities with a zero-dependency core Docs · GitHub · npm
@xtandard/flags A self-hosted, embeddable, OpenFeature-compatible feature-flag control plane with pluggable storage Docs · GitHub · npm
@xtandard/webhooks A self-hosted, embeddable, Standard Webhooks-compliant outbound-webhooks control plane: a Svix alternative as a library Docs · GitHub · npm
@xtandard/links Self-hosted, embeddable branded short links with click analytics, conversion attribution and deep links: a Dub / Bitly alternative as a library Docs · GitHub · npm
@xtandard/entitlements An embeddable entitlements, plans and usage-metering engine: typed catalog, atomic metering, any billing provider, admin UI and customer portal Docs · GitHub · npm
@xtandard/xyte A Zyte API-compatible /v1/extract client and server that runs on any proxy provider, or none Docs · GitHub · npm
xtandard-image A self-hosted image and video processing server in Go and libvips: imgproxy-compatible URLs plus the imgix, Cloudinary, ImageKit, Cloudflare and Thumbor dialects, with a TypeScript client (@xtandard/image) Docs · GitHub · npm

Related: drizzle-audit captures row-level changes in Drizzle ORM and forwards them here with @xtandard/audit/drizzle-audit (the bridge), and drizzle-cursor is cursor-based pagination for Drizzle. More: the xtandard ecosystem.