- Inngest Client (
/api/inngest/client.ts
): Initializes Inngest with therealtimeMiddleware
. - Realtime Channel (
/api/inngest/realtime.ts
): Defines a typed realtime channel and topic. - Chat Route:
/api/chat/route.ts
: This is a standard Next.js API route. Its only job is to receive a request from the frontend and send an event to Inngest to trigger a function. - Token Route:
/api/realtime/token/route.ts
: This secure endpoint generates a subscription token that the frontend needs to connect to Inngest realtime. - Inngest Route:
/api/inngest/route.ts
: The standard handler that serves all your Inngest functions.
1
Define server-side types
Define your server-side state type, import all your tools and pass them into
createToolManifest
to generate a type that you will use in your UI.2
Define client-side types
Create a
ClientState
type which will type state that your UI will send to your agent backend. This is a great place to pass along important context about the user or what they’re doing in your app.3
Create agents and an Inngest function to run them
4
Integrate a useAgent hook into your UI