Skip to main content

expo-asset

Version: 55.0.5 A universal module to download assets and pass them into other APIs. Simplifies asset management by providing automatic caching, downloading, and local URI access for bundled and remote assets.

Installation

Usage

API Reference

Asset Class

string
The name of the asset file
string
The file extension/type (e.g., ‘png’, ‘jpg’, ‘mp4’)
string | null
The MD5 hash of the asset’s content
string
The URI that points to the asset’s location (local or remote)
string | null
The local filesystem URI after the asset is downloaded. null if not yet downloaded.
number | null
Width in pixels for image assets
number | null
Height in pixels for image assets
boolean
Whether the asset has been downloaded to the local filesystem

Methods

(module: number) => Asset
Creates an Asset instance from a require() statement
(uri: string) => Asset
Creates an Asset instance from a URI string
(modules: number | number[]) => Promise<void>
Loads and caches assets by require() module IDs
() => Promise<void>
Downloads the asset to the local filesystem if not already downloaded

Examples

Preload Assets on App Start

Use with Image Component

Load Remote Asset

Pass to Video Player

Batch Asset Loading

Asset with Dimensions

Custom Asset Hook

App Plugin Configuration

For asset optimization during build: app.json:

TypeScript

Platform Support

On web, assets are loaded via HTTP and “downloading” is essentially ensuring they’re loaded in the browser cache.

Best Practices

  1. Preload Critical Assets: Load essential assets during app initialization
  2. Use Asset Caching: Assets are automatically cached after first download
  3. Handle Errors: Wrap downloadAsync() in try/catch blocks
  4. Batch Loading: Use Asset.loadAsync() for multiple assets
  5. Check Downloaded State: Verify asset.downloaded before using localUri

Resources