Skip to main content

Pieces

Everything an app does is a piece you define on its own, usually in its own file: There is no global app object to register handlers on. A piece knows what it needs: the scopes its code uses, the environment variables it reads, the install config it expects and the blocks it inserts. The app collects those requirements as you add pieces.

The app

createReintersectApp starts an empty app. Each add… call returns a new app with one more piece, so the order of calls doesn’t matter and nothing is mutated:
src/app.ts

App options

You upload your app’s icon in Settings → Developer → Apps → your app. It’s the only brand mark a block shows.

Requirements checked by TypeScript

app.fetch is the HTTP handler Reintersect calls. It only has a function type once every requirement is met. Until then, its type is an error that names what is missing, so mounting an incomplete app fails to compile:
The checks cover: The same checks run at runtime when you call add…, so plain JavaScript gets a clear error too.

Blocks inside other pieces

A command, message action, event handler, route or reference can produce or update a block. Use the block’s insert function, or list it in the piece’s blocks option, and the requirement travels in the types:
You can also write the answer’s block as JSX, such as <GoNoGo title="Ship v2" />. JSX erases to a generic element type, so TypeScript can’t record that requirement. reintersect check scans for it (jsx-block-unregistered), and the SDK rejects an unregistered block type at runtime. Prefer insert when you can.

Scopes

Scopes come from the pieces. A piece lists the scopes its own client calls need, and the app’s manifest scopes are the union of its pieces’ scopes plus the read scopes of the events it handles. Calling a client method whose scope the piece didn’t declare is a type error:
See Scopes.

Schemas

Props, state, args, input, env values and install config take any schema that implements both Standard Schema and Standard JSON Schema, because Reintersect needs the JSON Schema for forms, agents and validation: A schema without JSON Schema support is a type error that says how to fix it. Recursive schemas are rejected when the manifest syncs, and each schema must stay within the JSON Schema budget.

Export the app by name

Export the composed app as a named constant called app:
The CLI loads src/app.ts (or src/app.tsx, src/app.js, app.ts, …) unless you pass --entry or set "reintersect": { "entry": "…" } in package.json. For hosted apps the CLI generates the Worker entry that imports { app }. A default export also loads, but the CLI tells you to switch to the named export, because a bare default export is never checked against anything.

Hosted or mounted

You can host the same app value on Reintersect or mount it in your own server:
Reintersect builds and runs the app for you. You export app and deploy:
See Reintersect-hosted apps.

Sharing actions

Actions are standalone too. The same action can back a button on several blocks. When an action reads or writes block state, it declares the slice it needs, and defineBlock checks that slice against the block’s own state:
An action without a state slice is stateless. Agents run actions through the blocks they are rendered in; see Agents. To run shared logic from a command or a message action, call the same function from both handlers.