Skip to content

Paths and Resources

Uz.path is a global Uzumaki API for files and platform directories.

const logo = Uz.path.resource('assets/logo.svg');

Declare files in uzumaki.config.json:

{
"bundle": {
"resources": ["assets/**/*", "data/app.json"]
}
}

Resolve them at runtime:

const logo = Uz.path.resource('assets/logo.svg');
const config = Uz.path.resource('data/app.json');
<image src={logo} w={96} h={96} />;

resource(rel) returns an absolute path. The same call works in development and packaged builds.

APIDescription
resource(rel)Resolve a bundled resource to an absolute path.
resourceDirBundled resource root.
identifierApp id from config.
cacheDir()Platform cache directory, or null.
dataDir()Platform data directory, or null.
configDir()Platform config directory, or null.
tempDir()Writable temp directory.
exeDir()Directory of the running executable, or null.
homeDir()User home directory, or null.
import { join } from 'node:path';
const appData = join(
Uz.path.dataDir() ?? Uz.path.tempDir(),
Uz.path.identifier,
);

Use tempDir() as a fallback because some platform directories may be unavailable.

<image src> accepts:

  • Paths returned by Uz.path.resource(...)
  • Absolute file paths
  • file:// URLs
  • https:// URLs

Prefer bundled resources for app-owned assets such as icons, illustrations, and seed data.