@mastra/core
Version:
56 lines (35 loc) • 1.74 kB
Markdown
> Discover all available pages from the documentation index: https://mastra.ai/llms.txt
# Studio
Mastra configures [Studio](https://mastra.ai/docs/studio/overview) from a `studio.ts` file directly under `src/mastra/`. The file default-exports a `StudioConfig` object for Studio authentication and authorization: who can access Studio, and what authenticated users can do.
Use this page for the file-based convention. For auth providers, role-based access control (RBAC), and fine-grained authorization (FGA), see [Studio auth](https://mastra.ai/docs/studio/auth).
## Quickstart
For local development, you don't need `studio.ts`. Start the dev server and open Studio:
**npm**:
```bash
npm run dev
```
**pnpm**:
```bash
pnpm run dev
```
**Yarn**:
```bash
yarn dev
```
**Bun**:
```bash
bun run dev
```
Studio opens without authentication in local development. Add `studio.ts` when you're ready to secure a shared or production deployment.
## Add authentication
Use an auth provider to require sign-in before users can access Studio. This example uses [WorkOS](https://mastra.ai/docs/server/auth/workos):
```typescript
import { MastraAuthWorkos } from '@mastra/auth-workos'
import type { StudioConfig } from '@mastra/core/server'
export default {
auth: new MastraAuthWorkos(),
} satisfies StudioConfig
```
The auth provider handles who the user is. For what the user can do after sign-in, add RBAC or FGA in the same config. See [Studio auth](https://mastra.ai/docs/studio/auth) for full examples.
## Precedence with code
Code-registered Studio config wins over `studio.ts`. Use `studio.ts` when one project-wide Studio config is enough. Use code registration when auth depends on runtime wiring in `src/mastra/index.ts`.