React Frontend + Node Backend
Updated 6 hours ago • May 22, 2026
Use this shape when the UI and backend are deployed separately, or when backend ownership should stay independent from the React app.
The architecture rule is simple: the Node backend owns Kortyx execution. The React frontend consumes the stream protocol.
Backend Responsibilities
- Own
createAgent(...), workflows, nodes, providers, auth, rate limits, and runtime persistence. - Expose a chat route that accepts
messages,sessionId,workflowId, and approvedcontext. - Return SSE for live streaming.
- Return buffered JSON only for non-live clients or tests.
Frontend Responsibilities
- Use
@kortyx/reactfor chat state and transport. - Render finalized
messagesseparately from activestreamContentPieces. - Send only request metadata as client context.
- Never send provider credentials or server-only config to the browser.
Backend Route Shape
For a Fetch-compatible Node route, the handler can stay close to the Next.js API route shape.
Express, Fastify, Hono, and similar frameworks can adapt the same handler shape. Keep the same request body semantics and return the same SSE stream protocol.
Good to know: Always authenticate and rate-limit before calling
agent.streamChat(...). Treat clientcontextas request metadata only; derive user id, roles, tenant access, and billing access on the backend.
React Transport
On the frontend, point createRouteChatTransport(...) at the backend URL.
Custom Backends
Use a custom transport only when your backend cannot expose the standard Kortyx stream protocol. A custom transport must:
- preserve
sessionId,workflowId,messages, andcontextsemantics - call
onChunkfor every parsed stream chunk - forward
context.signaltofetchor the request layer soabort()works - surface transport errors instead of swallowing them
See React Client for the full transport shape.