Vanilla JS x Node
A vanilla-JS frontend (no framework) talking to a Node/Express backend that records audit events via sdk-node and serves the bundle on the same port. Comes in single-tenant and multi-tenant variants.
Source: https://github.com/everscribe/examples/tree/main/vanilla-js-fe-with-node-be
Stack
| Layer | What it is |
|---|---|
| Frontend | Plain HTML + ES modules + CSS, Vite for bundling, @everscribe/components-element |
| Backend | Node 20+, Express, tsx, @everscribe/sdk-node |
| Domain | In-memory secrets vault |
| Audit panel | <audit-trail> custom element |
Run it
git clone https://github.com/everscribe/examples
cd examples/vanilla-js-fe-with-node-be/single-tenant # or .../multi-tenant
cp .env.example .env # EVERSCRIBE_PROJECT_ID + EVERSCRIBE_API_KEY
npm install
cd frontend && npm install && npm run build && cd ..
npm start
Server on :3000 serves the bundle and the API.
Backend integration
Identical to the other Node variants:
import { create } from "@everscribe/sdk-node";
import * as minter from "@everscribe/sdk-node/minter";
const es = create(process.env.EVERSCRIBE_PROJECT_ID!, process.env.EVERSCRIBE_API_KEY!);
const rec = es.newRecorder({ flushInterval: 2_000 });
const m = new minter.Client(process.env.EVERSCRIBE_PROJECT_ID!, process.env.EVERSCRIBE_API_KEY!);
Recording per request:
await rec.record({
action: "secret.reveal",
actor: actorFor(req),
target: { type: "secret", id: req.params.id },
result: { status: "ok" },
});
See React + Node → Backend integration for the full mint endpoint.
Frontend integration
Plain HTML + a tiny module script:
<!doctype html>
<link rel="stylesheet" href="/style.css">
<link rel="stylesheet" href="https://unpkg.com/@everscribe/components-styles/default.css">
<main id="vault"></main>
<audit-trail token-endpoint="/api/embed-token"></audit-trail>
<script type="module">
import "@everscribe/components-element";
// ... vault UI code
</script>
For multi-tenant customer scoping, attach the demo auth header via onTokenExpired:
const el = document.querySelector("audit-trail");
el.onTokenExpired = async () => {
const res = await fetch("/api/embed-token/customer", {
credentials: "include",
headers: { "X-Demo-Actor": currentUser.id },
});
return (await res.json()).token;
};
Real apps swap X-Demo-Actor for whatever auth your backend expects.
Single-Tenant vs Multi-Tenant
| Single-tenant | Multi-tenant | |
|---|---|---|
| Token endpoint | One — /api/embed-token |
Two — /api/embed-token/customer, /api/embed-token/admin |
| UI | One vault view | Tab strip: Customer view · Admin view |
| Seeded data | One implicit tenant | Acme, Initech |
| Audit-panel scope | Whole project | Customer: tenant-scoped · Admin: unscoped |
What to take away
- Smallest stack of the matrix. No framework on the frontend, single Express process on the backend.
- The audit-trail tag is the entire embed. No wrapper component, no manual polling, no manual filter UI.
- Same backend code as the React and Svelte variants. Frontend choice is local.