Assets

    Uploading Assets

    Noya provides a binary asset upload API. The assets are synced between all users in the same Noya file.

    Assets are immutable once created. If you need to change an asset, you should create a new one.

    If you want to store a reference to an asset in the app state, you should store only the asset's id. This enables offline-first workflows.

    API Reference

    The API consists of the following methods:

    • createAsset(data: Uint8Array): Promise<Asset>
    • createAsset(blob: Blob): Promise<Asset>
    • createAsset(file: File): Promise<Asset>
    • createAsset(options: { contentType: string; data: Uint8Array }): Promise<Asset>
    • deleteAsset(id: string): Promise<void>

    You can access an up-to-date list of assets with the assets property in the state hook.

    Storing Assets Locally

    By default, Noya stores assets in-memory. To persist assets to IndexedDB, you can use the offlineStorageKey option when calling useNoyaState.