API reference › @evolu/common › Type › createId
function createId<B>(
deps: RandomBytesDep,
..._validation: IdBrandValidation<B>
): CreatedId<B>;
Defined in: packages/common/src/Type.ts:5939
Creates a cryptographically random Id.
This is the recommended default because it does not encode creation time. Pass a Brand name when the returned Id belongs to one domain entity.
Example
import {
assertTrue,
assertType,
Id,
createId,
createRandomBytes,
type Brand,
} from "@evolu/common";
const userId = createId<"User">({ randomBytes: createRandomBytes() });
assertTrue(Id.is(userId));
assertType<Id & Brand<"User">, typeof userId>();