#desktop #mobile #web

dioxus-asset-resolver

Cross-platform asset resolver for manganis and dioxus

13 releases

new 0.7.3 Jan 17, 2026
0.7.2 Dec 5, 2025
0.7.1 Nov 6, 2025
0.7.0 Oct 31, 2025
0.7.0-alpha.1 May 31, 2025

#1886 in Web programming

Download history 1153/week @ 2025-09-28 2494/week @ 2025-10-05 3118/week @ 2025-10-12 2807/week @ 2025-10-19 3192/week @ 2025-10-26 5804/week @ 2025-11-02 5652/week @ 2025-11-09 5434/week @ 2025-11-16 5611/week @ 2025-11-23 6477/week @ 2025-11-30 8134/week @ 2025-12-07 7411/week @ 2025-12-14 7893/week @ 2025-12-21 8510/week @ 2025-12-28 8714/week @ 2026-01-04 9690/week @ 2026-01-11

35,805 downloads per month
Used in 47 crates (5 directly)

MIT/Apache

28KB
342 lines

The asset resolver for the Dioxus bundle format. Each platform has its own way of resolving assets. This crate handles resolving assets in a cross-platform way.

There are two broad locations for assets depending on the platform:

  • Web: Assets are stored on a remote server and fetched via HTTP requests.
  • Native: Assets are read from the local bundle. Each platform has its own bundle structure which may store assets as a file at a specific path or in an opaque format like Android's AssetManager.

read_asset_bytes( abstracts over both of these methods, allowing you to read the bytes of an asset regardless of the platform.

If you know you are on a desktop platform, you can use asset_path to resolve the path of an asset and read the contents with std::fs.

Example

use dioxus::prelude::*;

// Bundle the static JSON asset into the application
static JSON_ASSET: Asset = asset!("/assets/data.json");

// Read the bytes of the JSON asset
let bytes = dioxus::asset_resolver::read_asset_bytes(&JSON_ASSET).await.unwrap();

// Deserialize the JSON data
let json: serde_json::Value = serde_json::from_slice(&bytes).unwrap();
assert_eq!(json["key"].as_str(), Some("value"));

Dependencies

~0.2–15MB
~146K SLoC