> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nanoforge.eu/llms.txt
> Use this file to discover all available pages before exploring further.

# @nanoforge-dev/asset

[![NanoForge](https://raw.githubusercontent.com/NanoForge-dev/Engine/main/.github/logo.png)](https://github.com/NanoForge-dev)

[![npm version](https://img.shields.io/npm/v/@nanoforge-dev/asset-manager.svg?maxAge=3600)](https://www.npmjs.com/package/@nanoforge-dev/asset-manager)

[![npm downloads](https://img.shields.io/npm/dt/@nanoforge-dev/asset-manager.svg?maxAge=3600)](https://www.npmjs.com/package/@nanoforge-dev/asset-manager)

[![Tests status](https://github.com/NanoForge-dev/Engine/actions/workflows/tests.yml/badge.svg)](https://github.com/NanoForge-dev/Engine/actions/workflows/tests.yml)

[![Last commit](https://img.shields.io/github/last-commit/NanoForge-dev/Engine.svg?logo=github\&logoColor=ffffff\&path=packages%2Fasset-manager)](https://github.com/NanoForge-dev/Engine/commits/main/packages/asset-manager)

[![Contributors](https://img.shields.io/github/contributors/NanoForge-dev/Engine.svg?maxAge=3600\&logo=github\&logoColor=fff\&color=00c7be)](https://github.com/NanoForge-dev/Engine/graphs/contributors)

## About

`@nanoforge-dev/asset-manager` is a manager for loading assets to uniform work with between client and server.

## Installation

**Node.js 26 or newer is required.**

```sh theme={null}
npm install @nanoforge-dev/asset-manager
yarn add @nanoforge-dev/asset-manager
pnpm add @nanoforge-dev/asset-manager
bun add @nanoforge-dev/asset-manager
```

## Example usage

Initialize the library in your main file

```ts theme={null}
import { AssetManagerLibrary } from "@nanoforge-dev/asset-manager";
import { type IRunOptions } from "@nanoforge-dev/common";
import { NanoforgeFactory } from "@nanoforge-dev/core";

export async function main(options: IRunOptions) {
  const app = NanoforgeFactory.createClient(); // Or NanoforgeFactory.createServer()

  const assetManager = new AssetManagerLibrary();

  app.useAssetManager(assetManager);

  await app.init(options);

  await app.run();
}
```

Use to load assets

```ts theme={null}
export async function mySystem(registry: Registry, ctx: Context) {
  const assetManager = ctx.libs.getAssetManager<AssetManagerLibrary>();

  const file = assetManager.getAsset("/path/to/file.txt");
  const text = await file.text();

  // Do something with file or text
}
```

## Links

* [GitHub][source]
* [npm][npm]

## Contributing

Before creating an issue, please ensure that it hasn't already been reported/suggested, and double-check the
[documentation][documentation].\
See [the contribution guide][contributing] if you'd like to submit a PR.

## Help

If you don't understand something in the documentation, you are experiencing problems, or you just need a gentle nudge in the right direction, please don't hesitate to ask questions in [discussions][discussions].

[documentation]: https://github.com/NanoForge-dev/Engine

[discussions]: https://github.com/NanoForge-dev/Engine/discussions

[source]: https://github.com/NanoForge-dev/Engine/tree/main/packages/asset-manager

[npm]: https://www.npmjs.com/package/@nanoforge-dev/asset-manager

[contributing]: https://github.com/NanoForge-dev/Engine/blob/main/.github/CONTRIBUTING.md

## Classes

* [AssetLibrary](https://docs.nanoforge.eu/references/engine/3.0.0/asset/classes/AssetLibrary.md)

## Variables

* [ASSET\_LIBRARY\_KEY](https://docs.nanoforge.eu/references/engine/3.0.0/asset/variables/ASSET_LIBRARY_KEY.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.