API reference@evolu/commonType › createIdAsUuidv7

function createIdAsUuidv7<B>(
  deps: RandomBytesDep & TimeDep,
  ..._validation: IdBrandValidation<B>
): CreatedId<B>;

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

Creates an Id whose bytes use the UUID v7 timestamp layout.

The timestamp can improve insertion locality for very large write-heavy indexes, but it exposes creation time anywhere the Id is copied, including logs, URLs, and exports. Prefer createId unless that tradeoff is deliberate.

Example

import {
  assertEqual,
  createIdAsUuidv7,
  createRandomBytes,
  createTime,
  idToIdBytes,
} from "@evolu/common";

const value = createIdAsUuidv7({
  randomBytes: createRandomBytes(),
  time: createTime(),
});
const bytes = idToIdBytes(value);

assertEqual(bytes[6] >> 4, 0x7);
assertEqual(bytes[8] & 0xc0, 0x80);