Targ Apps Docs
Chroma-Fs

Chroma-Fs as a plugin

Enable Chroma-Fs in an app through chroma.json and get a ready storage instance from the plugin loader.

Chroma-Fs is a first-party Chroma plugin. The general plugin mechanism (manifest, loader, vendoring) is described once in Plugins; this page covers only what is specific to chroma-fs.

Enable it

{
  "name": "my-app",
  "mode": "dynamic",
  "plugins": ["chroma-fs"]
}

The standard template already includes it. For static and dynamic apps, add the entry above and run chroma fs init.

What the loader gives you

The plugin's manifest declares loadAs: "fs" and the bootstrap hook bootstrapFs. When loadPlugins() runs, it calls bootstrapFs(), which creates storage from ./chroma-fs.json and exposes it as plugins.fs:

// src/main.chr
import { render } from "../pkg/chroma.js";
import { loadPlugins } from "../plugins/loader.js";
import { App } from "./App.chr";

const plugins = await loadPlugins();
await plugins.fs.writeFile("hello.txt", "Hello");

render(App, document.getElementById("app"));

Call loadPlugins() before render() so storage is ready when components mount.

Install and build

  • chroma install builds Chroma-Fs and stores it in $CHROMA_HOME/plugins/chroma-fs.
  • chroma new copies it into the project's plugins/ folder.
  • chroma build copies plugins/ and chroma-fs.json into dist/, so packaged apps keep working.

On this page