Skip to main content
Mastra v1 is coming in January 2026. Get ahead by starting new projects with the beta or upgrade your existing project today.

Integrate Cedar-OS with Mastra

Cedar-OS is an open-source agentic UI framework designed specifically for building the most ambitious AI-native applications. Cedar was built with Mastra in mind.

Should you use Cedar?Direct link to Should you use Cedar?

There are a few pillars Cedar cares about strongly that you can read more about here:

1. Developer experienceDirect link to 1. Developer experience

  • Every single component is downloaded shadcn-style – You own all the code and can style it however you want
  • Works out of the box – Just drop in the chat component, and it'll work
  • Fully extensible - Built on a Zustand store architecture that you can customize completely. Every single internal function can be overridden in one line.

2. Enabling truly AI-native applicationsDirect link to 2. Enabling truly AI-native applications

For the first time in history, products can come to life. Cedar is aimed at helping you build something with life.

  • Spells - Users can trigger AI from keyboard shortcuts, mouse events, text selection, and other components
  • State Diff Management - Give users control over accepting/rejecting agent outputs
  • Voice Integration - Let users control your app with their voice

Quick StartDirect link to Quick Start

  1. Run Cedar's CLI command:

    npx cedar-os-cli plant-seed

    If starting from scratch, select the Mastra starter template for a complete setup with both frontend and backend in a monorepo

    If you already have a Mastra backend, use the blank frontend cedar repo option instead. This will give you the option to download components and download all dependencies for Cedar. It is recommended to download at least one of the chat components to get started.

  2. Wrap your application with the CedarCopilot provider to connect to your Mastra backend:

    import { CedarCopilot } from "cedar-os";

    function App() {
    return (
    <CedarCopilot
    llmProvider={{
    provider: "mastra",
    baseURL: "http://localhost:4111", // default dev port for Mastra
    apiKey: process.env.NEXT_PUBLIC_MASTRA_API_KEY, // optional — only for backend auth
    }}
    >
    <YourApp />
    </CedarCopilot>
    );
    }
  3. Configure your Mastra backend to work with Cedar by following the Mastra Configuration Options.

    Register API routes in your Mastra server (or NextJS serverless routes if in a monorepo):

    import { registerApiRoute } from "@mastra/core/server";

    // POST /chat
    // The chat's non-streaming default endpoint
    registerApiRoute("/chat", {
    method: "POST",
    // …validate input w/ zod
    handler: async (c) => {
    /* your agent.generate() logic */
    },
    });

    // POST /chat/stream (SSE)
    // The chat's streaming default endpoint
    registerApiRoute("/chat/stream", {
    method: "POST",
    handler: async (c) => {
    /* stream agent output in SSE format */
    },
    });
  4. Drop Cedar components into your frontend – see Chat Overview.

    Your backend and frontend are now linked! You're ready to start building AI-native experiences with your Mastra agents.

More informationDirect link to More information

On this page