Your first app
A guided tour of a Chroma project - files, editor setup, linting, and optional storage.
This tutorial builds on the Quick start. You will look at what chroma new generated, set up editor checks, and optionally add storage.
New to programming? You do not need to know Rust. You write JavaScript in .chr files, edit one JSON file (chroma.json), and run a few commands. The editor extension and linter point you to the file to fix when something is wrong.
Checklist
- Install the CLI (Quick start)
- Create a project:
chroma new my-app --template dynamic(orstandardfor storage) - Open the project folder, not a single file, in VS Code or a compatible editor
- Install the Chroma extension (publisher
targapps, Open VSX) - Save
chroma.jsonand check the Problems panel - Read the
.chrformat before adding files undersrc/
Step 1: Run the generated app
chroma new hello-chroma --template dynamic
cd hello-chroma
chroma devThe CLI prints the URL it serves. The port comes from chroma.json (dev.port) or --port.
Step 2: Know the project files
| File | Purpose |
|---|---|
chroma.json | Project manifest: mode, build, plugins, dev settings |
index.html | HTML shell that loads the entry |
src/main.chr | Entry: imports App and calls render |
src/App.chr | Root component |
src/components/ | Your components, one per file |
Folder rules and build.jsEntry: .chr format.
Add a component:
// src/components/Greeting.chr
import { hookState, e } from "../../pkg/chroma.js";
export function Greeting() {
const [name, setName] = hookState("world");
return e(
"main",
null,
e("p", null, "Hello, ", name),
e("input", {
value: name,
onInput: (ev) => setName(ev.target.value),
}),
);
}Use it from App:
// src/App.chr
import { e } from "../pkg/chroma.js";
import { Greeting } from "./components/Greeting.chr";
export function App() {
return e("div", null, e(Greeting));
}Step 3: Editor checks and linting
The VS Code extension and @chroma/linter share one rule set: JSON Schema validation for manifests, plugin and build-entry checks, and .chr conventions.
- Install the Chroma extension.
- Open the folder that contains
chroma.json. - Save
chroma.json; the project is linted on save. - Run Chroma: Lint Project (
chroma.lintProject) from the Command Palette.
Details: VS Code extension, Linter.
Step 4: Storage with Chroma-Fs (optional)
chroma new notes --template standard
cd notes
chroma devThe standard template adds a storage example and chroma-fs.json. Backends and API: Chroma-Fs.
// src/storage.chr
import { createChromaFs } from "@chroma/fs";
const fs = await createChromaFs({ configPath: "./chroma-fs.json" });
await fs.writeFile("notes/hello.txt", "Hello from Chroma-Fs");When something goes wrong
| Symptom | What to check |
|---|---|
| Chroma: Lint Project is missing | The extension is not installed, or the window needs a reload. See VS Code extension. |
chroma/schema error in chroma.json | A key is missing, has the wrong type, or is not in the schema (the schema rejects unknown keys). See Linter. |
chroma/chr-only-extension | A .js file sits under src/ while .chr mode is active. Rename it to .chr. See .chr format. |
chroma-desktop not found | Run chroma dev --no-desktop, or reinstall the CLI. See CLI. |