const ALPHABET = 'abcdefghijklmnopqrstuvwxyz0123456789'; const LENGTH = 10; /** Short, URL-safe random ids: 10 base-36 characters (~51 bits). Works in browsers and Node. */ export function newId(): string { const bytes = crypto.getRandomValues(new Uint8Array(LENGTH)); let id = ''; for (const byte of bytes) id += ALPHABET[byte % ALPHABET.length]; return id; }