Deploying Mastra with NextJS
Hi there!
Loving Mastra so far, but getting to deployment now and I'm a little confused.
So I'm deploying this with my next.js app, and I was wondering how workflow streaming would work. In the docs, it says to include workflow streaming with ai sdk as WorkflowRoute in mastra index.ts - does this mean that its a seperate server? If I want to integrate it into my nextjs app with workflow streaming, does that needs to be a route hosted in my nextjs app or does including the mastra package in the external dependencies and the WorkflowRoute in the index.ts cover that?
Please let me know!
4 Replies
WorkflowRoute in mastra index.ts is uses mastra api that is separate server other then nextjs i would not choose this.
this will then be uses as
http://localhost:4111/workflow
The ideal way to work with nextjs is to install the mastra package in nextjs which is described here : https://mastra.ai/guides/v1/getting-started/next-js
after this you need to create a separate route in nextjs and implement your logic using workflow.streamVNext(...) same as agent.stream(...) in exampleYeah in NextJS you should use Mastra through NextJS
š Created GitHub issue: https://github.com/mastra-ai/mastra/issues/10818
š If you're experiencing an error, please provide a minimal reproducible example whenever possible to help us resolve it quickly.
š Thank you for helping us improve Mastra!
perfect! thanks for the info