API reference / @evolu/common / Type / createId

Function: createId()

function createId<B>(
  deps,
): [B] extends [never] ? string & Brand<"Id"> : string & Brand<"Id"> & Brand<B>;

Defined in: packages/common/src/Type.ts:1644

Creates a random Id. This is the recommended default.

Use createIdFromString for deterministic mapping of external IDs or createIdAsUuidv7 when you accept timestamp leakage for index locality.

Example

const id = createId(deps);
const todoId = createId<"Todo">(deps);

Type Parameters

Type ParameterDefault type
B extends stringnever

Parameters

ParameterType
depsRandomBytesDep

Returns

[B] extends [never] ? string & Brand<"Id"> : string & Brand<"Id"> & Brand<B>

Was this page helpful?