Getting started
Install
npm install @backroad/backroad
# or
pnpm add @backroad/backroad
@backroad/backroad carries the server runtime and the pre-built React
client. If you only need the shared types (for a custom frontend, or to
share an event type with another service), install @backroad/core instead.
Your first app
Create app.ts:
import { run } from '@backroad/backroad';
run((br) => {
br.write({ body: '# Hello, Backroad' });
const name = br.textInput({ label: 'Your name', defaultValue: 'world' });
if (name) {
br.write({ body: `Hello, **${name}**!` });
}
});
The executor receives a second argument with run-time context:
run((br, { currentPath }) => {
// currentPath is the URL pathname that triggered this run, e.g. '/settings'
});
Run it:
npx tsx app.ts
Open http://localhost:3333. The page renders the markdown, the input, and
re-runs the script as you type — your latest value goes back into the
textInput() call, the script outputs the new tree, the React client
paints it.