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?
2 Replies
Mastra Triager
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_6d 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 😉

Did you find this page helpful?