What Vibe Accounts is
Every visitor gets a generated name and avatar, kept with a passkey. No email, no password.
- Client: one ES module. Picker, chip, avatars and
data-vibebindings. - Server: one framework-free handler. Passkeys, sessions and
vibe.authenticate(request).
A saved account:
{
id: 'Xk3v9QmT7pLwR4aZ2bN8cA', // random, immutable; store this with authored content
name: 'VelvetComet', // public handle, unique (case-insensitive)
avatar: { style: 'neon', seed: 'k2x9' }, // re-rendered deterministically on any page
createdAt: 1760054400000
}
Avatars are stored as {style, seed}, never images. Free styles: pixel, minimal, neon, geometric, retro.
Your code, your data. Self-hosted Vibe Accounts never contacts VibeTools.
Install in one of three ways
All end with the client at /vibe-id/vibe-id.js, the endpoint at /api/vibe-id, and a script tag on every page.
Run from your project root. It writes VIBE-ACCOUNTS.md with the mount steps.
Paste into any coding agent. It runs the installer and wires identity through your app and server.
1. Copy two files from packages/id/dist and install the one dependency.
# browser client, served from your public/static directory
cp packages/id/dist/vibe-id.js public/vibe-id/vibe-id.js
# server module, imported by your backend
cp packages/id/dist/vibe-id-server.mjs lib/vibe-id/server.mjs
npm install @simplewebauthn/server
2. Mount the endpoint at /api/vibe-id. See adapters.
import { createVibeAccounts, fileStore } from './server.mjs';
export const vibe = createVibeAccounts({
appName: 'My App',
store: fileStore('.data/vibe-id.json'), // swap for a persistent store in production
rpID: process.env.VIBE_ID_RP_ID,
origins: process.env.VIBE_ID_ORIGINS?.split(',').map((s) => s.trim()),
});
3. Add the script tag to every page or your layout.
Client API
One VibeAccounts instance and two custom elements. UI renders in Shadow DOM, so CSS never collides. The old names VibeID, createVibeId and <vibe-id-chip> still work as aliases.
VibeAccounts.init(options)
Call once per page. Paints from local state, then resolves when the server answers. If the server is unreachable, it runs guest-only.
| Option | Type | Default | Description |
|---|---|---|---|
endpoint | string | null | '/api/vibe-id' | Base URL of the Vibe Accounts handler. null runs guest-only with no passkeys. |
appName | string | document.title | Shown in the welcome animation and recovery-code file. |
theme | object | {} | Theme JSON from the studio. See Theming. |
chip | 'auto' | 'none' | selector | Element | 'auto' | 'auto' floats the chip top-right unless a <vibe-accounts-chip> exists on the page. A selector or element mounts it there. |
menu | Array | [] | Your own items in the chip menu: [{ label, href | onClick, when?: 'guest'|'account' }]. href may be a function of the user. |
prompt | 'first-visit' | 'manual' | 'first-visit' | Open the picker automatically for visitors without an identity, or only when you call choose(). |
bind | boolean | true | Fill [data-vibe] elements and keep them in sync, including elements added later. |
nudge | boolean | true | After a guest picks an identity, suggest saving it with a passkey. |
Properties and methods
| Member | Description |
|---|---|
VibeAccounts.user | {id, name, avatar:{style,seed}, guest, saved} or null. guest: true means local-only; saved: true means a passkey account with a live session. |
VibeAccounts.ready | true once init() has heard from the server. |
on(event, fn) | Subscribe. Returns an unsubscribe function. Events: change, ready, saved ({user, guestId}), signin, signout, deleted. off(event, fn) also works. |
choose() | Open the identity picker. Resolves with the chosen user, or null if dismissed. |
mountPicker(el, opts) | Render the picker inline inside el. { theme, preview: true } plays the welcome animation without saving anything (for previews and theme editors). |
save() | Register a passkey and turn the current guest into an account. Shows the recovery code once. Resolves with the user, or null if cancelled. |
signIn() | Sign in with any passkey for this site. No username: the OS lists the accounts. |
signOut() | Revokes the server session and falls back to the local guest, if any. |
deleteAccount() | Deletes the account on the server (or the local guest). Irreversible. |
rename(name) | Change the display name. Server-checked for uniqueness and the blocklist. setAvatar(avatar) changes the avatar. |
fetch(url, init) | Same as fetch(), plus the session cookie, the X-Vibe-ID: 1 header and, for guests, an X-Vibe-Guest header. Use it for your own API calls. |
avatarSVG(avatar, size) | SVG markup for {style, seed}, themed. avatarURL(avatar, size) returns a data: URL for <img>. |
setTheme(theme) | Swap the theme at runtime; the chip and bound elements re-render. |
addPasskey() | Register another passkey on the current account (a second device or a security key). passkeys() lists them; removePasskey(id) removes one. |
newRecoveryCode() | Rotate the recovery code and show the new one. recover(code) signs in with a code. |
profile(id) | Public profile {id, name, avatar, createdAt} for any user id. |
Web components and data attributes
No script needed. The avatar attribute is avatar-style, since style is taken.
<!-- Render any user's avatar from the stored {style, seed} -->
<vibe-avatar avatar-style="neon" seed="k2x9" size="40"></vibe-avatar>
<!-- Or by user id (fetches the public profile) -->
<vibe-avatar user-id="Xk3v9QmT7pLwR4aZ2bN8cA" size="32"></vibe-avatar>
<!-- Place the identity chip inline instead of floating top-right -->
<vibe-accounts-chip></vibe-accounts-chip>
<!-- Bindings: filled from VibeAccounts.user and kept in sync -->
<span data-vibe="avatar" data-size="28"></span>
<b data-vibe="name" data-vibe-empty="Anonymous"></b>
<small data-vibe="badge"></small> <!-- "Guest" or "Saved" -->
<!-- Conditional: user | none | guest | account -->
<p data-vibe-if="guest">Save your identity with a passkey to post.</p>
<a href="/me" data-vibe-if="account">Your profile</a>
Example: a comment list
Author fields come from vibe.authenticate() on the server, never the browser.
import { VibeAccounts } from '/vibe-id/vibe-id.js';
await VibeAccounts.init({ endpoint: '/api/vibe-id', appName: 'My App' });
const list = document.querySelector('#comments');
const form = document.querySelector('#new-comment');
function renderComment(c) {
const li = document.createElement('li');
const avatar = document.createElement('vibe-avatar');
avatar.setAttribute('avatar-style', c.authorAvatar.style);
avatar.setAttribute('seed', c.authorAvatar.seed);
avatar.setAttribute('size', '32');
const name = document.createElement('a');
name.href = `/u/${encodeURIComponent(c.authorId)}`;
name.textContent = c.authorName; // textContent: never innerHTML user input
const body = document.createElement('p');
body.textContent = c.text;
li.append(avatar, name, body);
return li;
}
async function load() {
const { comments } = await (await fetch('/api/comments')).json();
list.replaceChildren(...comments.map(renderComment));
}
form.addEventListener('submit', async (e) => {
e.preventDefault();
if (!VibeAccounts.user?.saved) { // guests save first, then post
if (!(await VibeAccounts.save())) return;
}
const res = await VibeAccounts.fetch('/api/comments', {
method: 'POST',
headers: { 'content-type': 'application/json' },
body: JSON.stringify({ text: form.text.value }),
});
if (res.ok) { form.reset(); load(); }
});
VibeAccounts.on('change', load); // names re-render after a rename
load();
Server API
One Fetch API handler: vibe.handle(request) → Response, under /api/vibe-id by default. Mutating routes need X-Vibe-ID: 1 and an allowed Origin.
HTTP endpoints
| Method | Path | Auth | Purpose |
|---|---|---|---|
| GET | /me | optional | {user | null} for the current session. |
| POST | /register/options | none | Body {name, avatar}. Returns passkey creation options. Reserves nothing yet. |
| POST | /register/verify | challenge | Creates the account and a session. Returns {user, recoveryCode}. |
| POST | /login/options | none | Discoverable-credential options (no username). |
| POST | /login/verify | challenge | Verifies the assertion, starts a session. Returns {user}. |
| POST | /passkeys/options | session | Options to add another passkey to the account. |
| POST | /passkeys/verify | session | Stores the additional passkey. |
| PATCH | /me | session | Body {name?, avatar?}. Rename or change avatar. |
| POST | /recovery/new | session | Rotates the recovery code. Returns {recoveryCode}. |
| POST | /recovery | none | Body {code}. One-time sign-in; the code burns. |
| POST | /logout | session | Revokes the current session. |
| DELETE | /me | session | Deletes the user, credentials, name and all sessions. |
| GET | /users/:id | none | Public profile {id, name, avatar, createdAt}. |
| GET | /names/check?name= | none | {ok, reason?, suggestion?}. Validity and availability. |
| GET | /passkeys | session | List the account's passkeys (id, created, last used, synced). |
| DELETE | /passkeys/:id | session | Remove a passkey. Refuses to remove the last one. |
Errors are JSON: {"error": "name_taken", "message": "…", "suggestion": "VelvetComet412"}. Codes: not_signed_in (401), missing_csrf_header, bad_origin (403), name_taken (409), invalid_name, challenge_expired, invalid_code (400), rate_limited (429).
createVibeAccounts(options)
| Option | Default | Description |
|---|---|---|
store | required | Any object with async get(key), set(key, json), delete(key). See stores. |
appName | 'Vibe Accounts' | Relying-party name shown in the OS passkey sheet. |
rpID | request host | WebAuthn RP ID: your registrable domain, e.g. example.com. Passkeys are bound to it. |
origins | request origin | Allowed origins for WebAuthn and the CSRF Origin check, e.g. ['https://example.com']. |
basePath | '/api/vibe-id' | Where the handler is mounted. |
sessionDays | 90 | Session lifetime in days. |
publicProfiles | true | Expose GET /users/:id. |
customNames | false | Generated names only by default, enforced server-side even for direct API calls. true allows typed names (still filtered). |
names | none | Theme vocabulary ({adjectives, nouns, prefixes, suffixes}) so branded names pass the generated-only check. |
blockedWords | [] | Extra forbidden words, on top of the built-in filter (word-boundary aware, catches leetspeak and split spellings). |
rateLimit | { windowMs: 600000, max: 60 } | Per-IP, per-action window. Sensitive routes use tighter caps. false disables it. |
onEvent | none | Called with {type, id, at} for account.created, session.created, account.recovered, account.deleted. id is pseudonymous. Never receives PII. |
Returns { handle, authenticate, identity, getUser, express, node, basePath, store }. getUser(id) returns the public profile, or null once deleted; use it at read time so renames show.
Attributing content: vibe.authenticate(request)
Returns {id, name, avatar, createdAt} for a signed-in account, or null. Store the immutable id and ignore identity fields in the body.
import { vibe } from '../../lib/vibe-id/instance.mjs';
import { db } from '../../lib/db.mjs'; // your storage
export default async (request) => {
if (request.method === 'GET') {
return Response.json({ comments: await db.comments.latest(50) });
}
if (request.method !== 'POST') return new Response(null, { status: 405 });
// Same CSRF rule as Vibe Accounts itself: VibeAccounts.fetch() always sends this header.
if (request.headers.get('x-vibe-id') !== '1') {
return Response.json({ error: 'missing_csrf_header', message: 'Missing X-Vibe-ID header.' }, { status: 403 });
}
const user = await vibe.authenticate(request);
if (!user) {
return Response.json({ error: 'not_signed_in', message: 'Save your identity to comment.' }, { status: 401 });
}
const { text } = await request.json(); // any authorId / authorName in the body is ignored
const comment = {
id: crypto.randomUUID(),
text: String(text ?? '').slice(0, 2000),
authorId: user.id, // immutable: join on this
authorName: user.name, // snapshot for fast rendering
authorAvatar: { style: user.avatar.style, seed: user.avatar.seed },
createdAt: Date.now(),
};
await db.comments.insert(comment);
return Response.json({ comment }, { status: 201 });
};
export const config = { path: '/api/comments' };
Guest actions. vibe.identity(request) returns {kind: 'account', verified: true, user} or {kind: 'guest', verified: false, user} (from X-Vibe-Guest). Guests are unverified: fine for likes, never for ownership.
Stores
| Store | Use for |
|---|---|
memoryStore() | Tests. Data is lost on restart. |
fileStore(path) | Local dev or one long-running server with a persistent disk. Atomic, single process. Loses everything on serverless. |
netlifyBlobsStore(getStore) | Netlify. Pass a function (created per request): netlifyBlobsStore(() => getStore({ name: 'vibe-id', consistency: 'strong' })). |
Anything else (Redis, KV, SQL): implement the three async methods. Values are JSON.
Adapters
import { vibe } from '../../lib/vibe-id/instance.mjs';
export default (req) => vibe.handle(req);
export const config = { path: ['/api/vibe-id', '/api/vibe-id/*'] };
import { vibe } from '@/lib/vibe-id/instance.mjs';
export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';
const handler = (req) => vibe.handle(req);
export { handler as GET, handler as POST, handler as PATCH, handler as DELETE };
Pages Router: export default vibe.node() in pages/api/vibe-id/[...path].js with export const config = { api: { bodyParser: false } }.
import express from 'express';
import { vibe } from './lib/vibe-id/instance.mjs';
const app = express();
app.use('/api/vibe-id', vibe.express()); // reads the raw body itself; mount before express.json() or after, both work
app.use(express.static('public'));
app.listen(3000);
import http from 'node:http';
import { vibe } from './lib/vibe-id/instance.mjs';
const api = vibe.node();
http.createServer((req, res) => {
if (req.url.startsWith('/api/vibe-id')) return api(req, res);
// ...serve the rest of your app
}).listen(8787);
First admin: one-time setup code
The installer prints an admin setup code (VIBE-XXXX-XXXX-XXXX) once, to whoever installed. Only a salted hash is stored (adminClaim in lib/vibe-id/instance.mjs). Sign up on your site with a passkey, open the admin dashboard and enter the code: that account becomes the first admin and adds other admins in the panel. The code works once and expires after 30 days; vibe-tools admin code writes a new one while no admin exists yet.
Dashboard: --dashboard vibe writes a ready page at /vibe-admin/ (sign in, claim, then Vibe Settings); --dashboard existing means you mount VibeSuite.mountSettings or VibeAccounts.mountSettings on your own admin page, which shows the claim form to a signed-in non-admin. Every Vibe tool uses vibe.isAdmin(request) as its admin check.
Environment
| Variable | Example | Purpose |
|---|---|---|
VIBE_ID_RP_ID | example.com | Passed as rpID. Use localhost in dev. |
VIBE_ID_ORIGINS | https://example.com,http://localhost:8888 | Comma-separated, passed as origins. |
VIBE_ADMIN_CLAIM | vcl1$… | Optional. Overrides the admin claim baked into instance.mjs. |
VIBE_ADMIN_IDS | Xk3v9QmT…,Lp2… | Optional recovery backstop: account ids that are always admins. |
HTTPS required in production. Passkeys need a secure origin; http://localhost is exempt. Cookies are Secure on HTTPS.
Security model
- Passkeys, verified server-side with
@simplewebauthn/server. Discoverable (residentKey: required),userVerification: preferred, attestationnone. Challenges are single-use, 5-minute expiry. - Opaque, revocable sessions. Random 256-bit token in an
HttpOnly; Secure; SameSite=Laxcookie. Only its SHA-256 hash is stored, so a leaked store cannot be replayed. No signing secret to leak. - CSRF, three layers.
X-Vibe-ID: 1header (forces a CORS preflight), allow-listedOrigin, andSameSite=Lax. - Rate limiting per action, on a salted IP hash. Salt is per process; IPs are never stored.
- Recovery codes: 130 bits, shown once, SHA-256 hashed, burn on use.
- Names block impersonation words (admin, mod, official, support) and are unique case-insensitively.
- Complete deletion.
DELETE /meremoves the user, credentials, name, recovery code and sessions.
Works with Face ID, Touch ID, Windows Hello, Android and security keys. Biometrics never leave the device: the server sees only a public key and counter.
What is stored
Stored
- Random user id
- Display name
- Avatar
{style, seed} - Passkey public key and signature counter
- Created date
- Hashed session tokens and recovery code
Never stored
- Email or phone number
- Real name
- Photos
- Biometrics of any kind
- IP addresses (salted hash, in memory only)
Pseudonymous is not legally anonymous. Posts can still identify people, and your app may log more. VibeTools claims no SOC 2 or other certification.
Guests are local-only
Guests live in localStorage['vibe-id:guest']. No server record, no hosting cost.
- Clearing site data or closing a private window deletes an unsaved guest.
VibeAccounts.save()turns it into a passkey account.- Common split: guests read and like; save to post.
async function requireAccount() {
if (VibeAccounts.user?.saved) return true;
return !!(await VibeAccounts.save()); // opens the picker first if there is no identity at all
}
Recovering an account
No email reset. Two options:
- More passkeys.
VibeAccounts.addPasskey()adds a device or hardware key. Synced passkeys cover most device changes. - One recovery code, shown once at save.
VibeAccounts.recover(code)signs in once and burns it;newRecoveryCode()issues another.
Lose both and the account is gone. That is the cost of no contact details.
Theming
Build one in the studio and pass it to init({ theme }) or setTheme(theme). Invalid values fall back to defaults.
{
"name": "Vibe Default",
"version": 1,
"avatar": {
"style": "pixel", // pixel | minimal | neon | geometric | retro
"palette": ["#c6ff3d", "#2ee6ff", "#ffb547", "#7c8cff"],
"background": "gradient", // solid | gradient | none
"shape": "squircle" // circle | squircle | hex | square
},
"names": {
"style": "playful", // playful | fantasy | futuristic | nature | abstract
"adjectives": [], "nouns": [], "patterns": []
},
"ui": {
"accent": "#c6ff3d", "accent2": "#2ee6ff",
"bg": "#0a0c0f", "surface": "#12151a", "text": "#e8ece6",
"font": "Inter", "radius": 14,
"button": "solid", // solid | outline | glow
"animation": "burst", // burst | warp | glitch | calm | none
"backdrop": "blur", // blur | solid | grid | stars
"title": "Pick your identity"
}
}
Themes change looks, not stored data.
Vibe Cloud Planned
Not available. No Vibe Cloud endpoint, API key or sign-up exists. Treat any URL claiming to be one as fake.
If it ships, a tenant would send only a tenant id, hashed MAU counts and credential public keys. Self-hosted never contacts VibeTools.
Troubleshooting
The browser never offers to create a passkey
Use HTTPS or http://localhost; a LAN IP like http://192.168.1.20 fails. rpID must be the page's domain or a parent (example.com covers app.example.com). VibeAccounts.supportsPasskeys() checks WebAuthn support.
Every save fails with "Origin not allowed"
Add the exact scheme, host and port to VIBE_ID_ORIGINS, including preview deploys. missing_csrf_header means the call bypassed VibeAccounts.fetch.
A user lost their guest identity
Unsaved guests live in one browser only; the server has no copy. The default nudge prompts users to save.
How do renames affect old content?
Rename frees the old name immediately. Join on the immutable authorId; stored authorName is only a cache.
Can two people have the same name?
Not among saved accounts; a clash returns a suggestion. Two guests can share one until someone saves.
Will passkeys survive moving to a new domain?
No, they are bound to the RP ID. Users add a passkey on the new domain or use their recovery code.
Source: packages/id (repository not public yet).