Initial Configuration
1
Set up your project
Run
plant-seed
and select either:- Mastra starter - for a complete setup with both frontend and backend
- Mastra reference repo - to see a full implementation example
create-mastra
CLI.2
Wrap your app with CedarCopilot
Wrap your application with the CedarCopilot provider to connect to your Mastra backend:
3
Configure Mastra endpoints to talk to Cedar
Configure your Mastra backend to work with Cedar by following the Mastra-specific configuration options: Mastra Configuration OptionsRegister API routes in your Mastra server so Cedar’s chat components have something to talk to:
mastra/src/index.ts
4
Add Cedar Chat
Drop a Cedar chat component into your frontend – see Chat Overview.
Your backend and frontend are now linked! You’re ready to start bringing the power of your Mastra agentic workflows to your UI.
Type Safety
Mastra backends support full end-to-end type safety usingMastraParams<T, E>
:
MastraParams
type allows you to:
- T: Define types for your
additionalContext
data - E: Define types for custom fields (userId, sessionId, etc.)
Features to explore
Now that you have Cedar-OS connected to Mastra, explore these powerful features:- State Access & Manipulation - Use the
useRegisterState
hook for communicating frontend state and letting agents manipulate your frontend state - Mentions & Context - Send @ mentions to your backend using the
useStateBasedMentionProvider
New to Mastra? Here are a few primitives to understand
Deployment
The recommended deployment setup is:- Frontend: Deploy to Vercel for optimal performance and seamless integration
- Backend: Use Mastra Cloud for hosting your Mastra server
Next Steps
- Clone & run the cedar-mastra-starter to see everything in action.
- Explore the official Mastra docs for further customisation.