Download and configure the official IC assets canister with asset synchronization capabilities.
Example of how to reference this recipe in an icp.yaml file:
canister:
name: frontend
recipe:
type: "@dfinity/assets"
configuration:
version: 0.23.0
dir: dist| Parameter | Type | Required | Description | Default |
|---|---|---|---|---|
| version | string | No | SDK version tag to download assets canister from, defaults to using the main branch | - |
| dir | string | Yes | Directory containing frontend assets to synchronize | - |
| metadata | array | No | Array of key-value pairs for custom metadata | [] |
ic-wasmtool must be installed for metadata injection and optimization- Frontend assets must be built and available in the specified directory
- Internet connection required to download the assets canister WASM
canister:
name: website
recipe:
type: "@dfinity/assets"
configuration:
dir: buildcanister:
name: spa-frontend
recipe:
type: "@dfinity/assets"
configuration:
version: 0.23.0
dir: dist
metadata:
- name: "frontend:framework"
value: "react"
- name: "frontend:version"
value: "1.0.0"When this recipe is executed:
- Downloads the official assets canister WASM from the specified SDK version
- Injects any custom metadata specified in the configuration
- Configures asset synchronization for the specified directory
The assets canister automatically synchronizes files from your specified directory:
- Static files: HTML, CSS, JS, images, fonts, etc.
- SPA support: Handles client-side routing with fallback to index.html
- Content encoding: Automatic gzip compression for supported file types
- Cache headers: Optimized caching for static assets
Problem: Failed to download assets canister WASM Solution: Check your internet connection and verify the SDK version exists at https://github.com/dfinity/sdk/releases
Problem: Assets directory not found Solution: Ensure your frontend is built and the specified directory contains the compiled assets
Problem: Asset synchronization not working Solution: Verify your assets directory structure and check that files are accessible and not too large
- Pre-built Recipe - For using custom pre-compiled WASM files
- Rust Recipe - For building backend Rust canisters
- Motoko Recipe - For building backend Motoko canisters
Use this recipe for frontend applications that need to serve static assets and web content on the Internet Computer.
- v1.0.0 - Initial release with assets canister support and synchronization