TLAssetId

See source code

Branded string type for asset record identifiers. Prevents mixing asset IDs with other types of record IDs at compile time.

type TLAssetId = RecordId<TLBaseAsset<any, any>>;

Example

import { createAssetId } from "@tldraw/tlschema";

// Create a new asset ID
const assetId: TLAssetId = createAssetId();

// Use in asset records
const asset: TLAsset = {
  id: assetId,
  // ... other properties
};

// Reference in shapes
const imageShape: TLImageShape = {
  props: {
    assetId: assetId,
    // ... other properties
  },
};
Prev
TLAsset
Next
TLAssetPartial