Skip to content
VaelJS Blog

vael:uuid/v4

RFC 9562 version 4 (random) UUID generator.

Available in both vjs (vaeljs) and vjs-lite (vaeljs-lite) runtimes. Exports the same synchronous CSPRNG-backed v4 function as "vael:uuid".

import ... from "vael:uuid/v4"
Since v0.0.0-alpha.0 vjs (V8) vjs-lite (QuickJS)
Cargo feature: Always enabled in vaeljs-core; vael-uuid (default) in vaeljs-lite-core
import v4 from "vael:uuid/v4";
console.log(v4());
functionSince v0.0.0-alpha.0vjs & vjs-lite
export function v4(): string;

Generate a canonical lowercase RFC 9562 version 4 (random) UUID string (36 characters) using the OS CSPRNG.

Identical function object to v4 from "vael:uuid".

Returns
string — Canonical 36-character lowercase RFC 9562 UUIDv4 string.
Exceptions
  • TypeError — when any argument is supplied.
  • Error — with code = "VAEL_UUID_RANDOM" when the OS CSPRNG fails.
import { v4 } from "vael:uuid/v4";
console.log(v4().length); // 36
defaultSince v0.0.0-alpha.0vjs & vjs-lite
export default v4;

Default export: identical to v4.