Assets

Assets are records that store data about shared resources like images and videos. Shapes reference assets by ID rather than embedding files directly, so you can reuse the same image across multiple shapes without duplicating data.

For the complete guide to working with assets, see the Assets reference.

Default storage behavior

TLAssetStore controls how assets are uploaded and resolved. The default depends on your store setup:

SetupAsset storeWhere files go
In-memory only (default)inlineBase64AssetStoreData URLs inside the document
persistenceKeyBuilt in, overridable with the assets propThe browser's IndexedDB
Sync serverYour own TLAssetStore, passed to useSyncA storage service like S3 or R2

To use your own storage, implement upload and resolve and pass the store to <Tldraw> (or to useSync):

import { Tldraw, TLAssetStore } from 'tldraw'
import 'tldraw/tldraw.css'

const myAssetStore: TLAssetStore = {
	async upload(asset, file) {
		const url = await uploadToMyServer(file)
		return { src: url }
	},
	resolve(asset) {
		return asset.props.src
	},
}

export default function App() {
	return (
		<div style={{ position: 'fixed', inset: 0 }}>
			<Tldraw assets={myAssetStore} />
		</div>
	)
}

resolve also receives a TLAssetContext with the current screen scale and DPR, so you can serve a resized image instead of the original. Pasted and dropped files go through the external content handlers before they become assets.

Examples

Prev
Persistence
Next
Indicators