Declare the endpoint
src/reintersect/app.ts
POST requests to endpoint for every block render, action, insert, select
search, reference resolve and search, command, message action and event. The endpoint’s path ending in
/reintersect is the delivery path; the part before it (/api here) is the app’s root, where
routes and the MCP server (/mcp) are served. The SDK checks the
webhook signature on every delivery and rejects anything unsigned, stale or
replayed.
Endpoints must be HTTPS on the default port and resolve to public addresses. Reintersect doesn’t
follow redirects from them.
Environment
Set these on your server:
Also set the variables your app declares in
env. The SDK reads them from the environment, or from the
env object you pass as the second argument of app.fetch (as Workers does).
Mount the app
app.fetch(request, env?, ctx?) is a standard fetch handler. It only has a function type once the
app is complete: if a piece needs a block, environment variable or service the app doesn’t provide,
the mount is a type error that names what is missing. Mount it so it receives the delivery path, your
routes and /mcp.
- Next.js
- Hono on Bun
- Deno
- Node
- Cloudflare Workers
- Effect
A catch-all route under The project’s JSX is Reintersect JSX; start any React page or component with
/api, as the Next.js template writes it:src/app/api/[[...path]]/route.ts
/** @jsxImportSource react */.Install tokens
A self-hosted app keeps only install ids and never stores Reintersect tokens:- Inside a delivery, the body carries a one-hour install token for that install, and the handler’s
reintersectclient uses it. Action deliveries also carry an interaction token for the one block, valid for 15 minutes. - Outside a delivery (routes, cron jobs, your own backend), call
reintersect.forInstall(installId)in a route, orcreateReintersectClient(app, { installId })anywhere. The SDK mints a one-hour token with your client credentials (POST /v0/apps/installs/:installId/access-tokens), caches it and renews it before it expires.
app.installed event, and forget them on app.uninstalled.
Local development
reintersect dev builds your app with esbuild, runs it in a local Node server, and relays deliveries
for your development install to it. The relay replays the exact signed request production would send,
so signature checks run locally too. Your endpoint doesn’t need to be reachable from the internet
while you develop. Pick the local port with --port.
To run your framework’s own dev server (npm run dev:next in the Next.js template), start it next to
reintersect dev; deliveries during development still go to the CLI’s local server.