M
Mastra2mo ago
wiz2202

Streaming to frontend

We’re starting to build more workflows in Mastra (inside a Next.js app) and want to standardize how we handle front-end streaming so each new workflow doesn’t have to reinvent the logic. We’re currently deciding between two approaches: Directly streaming from Mastra, using its built-in event stream and snapshots (getSnapshot, etc.) for resume and progress updates. Adding our own lightweight event-log layer, where our server listens to Mastra workflow events, stores them in a RunEvent table, and exposes an SSE endpoint for the front-end to consume. Do you have any recommendations or best practices for teams standardizing streaming at scale with Mastra? For example—does Mastra plan to expose a public event stream API or recommend a pattern similar to the Playground?
3 Replies
Mastra Triager
Mastra Triager2mo ago
GitHub
mastra-ai/mastra
The TypeScript AI agent framework. ⚡ Assistants, RAG, observability. Supports any LLM: GPT-4, Claude, Gemini, Llama. - mastra-ai/mastra
_roamin_
_roamin_2mo ago
Hey @wiz2202 ! Are you looking to have a single stream endpoint that emits events for all the running workflows? Just trying to better understand what you're trying to achieve 😉
Abhi Aiyer
Abhi Aiyer3w ago
Both mastra agents and workflows have stream outputs with distinct types. We have these compatible with UI frameworks. For some examples to look at you can see here https://github.com/mastra-ai/ui-dojo. I think using the streams we provide natively is recommended.

Did you find this page helpful?