API reference / @evolu/common / Type / createIdAsUuidv7

Function: createIdAsUuidv7()

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

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

Creates an Id embedding timestamp bits (UUID v7 layout) before Base64Url encoding.

Tradeoff: better insertion locality / index performance for huge datasets vs leaking creation time everywhere the Id appears. Evolu uses createId by default to avoid activity leakage; choose this only if you explicitly accept timestamp exposure.

Example

const id = createIdAsUuidv7({ randomBytes, time });
const todoId = createIdAsUuidv7<"Todo">({ randomBytes, time });

Type Parameters

Type ParameterDefault type
B extends stringnever

Parameters

ParameterType
depsRandomBytesDep & TimeDep

Returns

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

Was this page helpful?