createCustomRecordId

See source code

Creates a unique ID for a custom record type.

function createCustomRecordId<T extends string>(
  typeName: T,
  id?: string,
): RecordId<UnknownRecord> & `${T}:${string}`;

Example

// Create with auto-generated ID
const commentId = createCustomRecordId("comment"); // 'comment:abc123'

// Create with custom ID
const customId = createCustomRecordId("comment", "my-comment"); // 'comment:my-comment'

Parameters

NameDescription

typeName

T;

The type name of the custom record

id

string;

Optional custom ID suffix. If not provided, a unique ID will be generated

Returns

RecordId<UnknownRecord> & `${T}:${string}`;

A properly formatted record ID

Prev
createCachedUserResolve
Next
createCustomRecordMigrationIds