Quickstart (Next.js Server Action)
This quickstart matches the current OSS implementation and mirrors examples/kortyx-nextjs-chat-server-action.
Good to know: As of Next.js 16.1.6 (March 8, 2026), Server Actions return after completion and do not stream chunk updates to client UI in real time. For live token/chunk rendering, use Quickstart (Next.js API Route).
1. Create a workflow
src/workflows/general-chat.workflow.ts
2. Initialize provider bootstrap
src/lib/providers.ts
3. Create a node
src/nodes/chat.node.ts
4. Wire an agent
src/lib/kortyx-client.ts
5. Call streamChat (buffered in server action)
src/app/actions/chat.ts
src/app/actions/chat.js
Good to know: Use
collectStream(...)when you want to process raw chunk events yourself. UsecollectBufferedStream(...)when you want merged text + structured summaries.
6. Run
What this gives you
- Type-safe workflow definition
- Explicit provider bootstrap at app level
- Node-level model control via
useReason(...) - Buffered chunk collection through a Server Action return value
- Chunk event types in the buffered result (
text-start,text-delta,text-end,message,done) - Built-in interrupt/resume path when your nodes use
useInterrupt
Next: