Skip to main content
Mastra provides a modular plugin architecture that allows you to integrate different storage backends, vector stores, authentication providers, and server adapters into your applications.

Integration Categories

Storage Adapters

Storage adapters provide persistence for workflows, memory, observability, and other domains in Mastra:
  • LibSQL - SQLite-compatible storage with Turso support
  • PostgreSQL - Production-grade relational storage
  • MongoDB - Document-based NoSQL storage
  • DynamoDB - AWS serverless NoSQL database

Vector Stores

Vector stores enable semantic search and similarity matching for RAG applications:
  • Pinecone - Managed vector database service
  • Qdrant - Open-source vector search engine
  • Chroma - AI-native embedding database
  • pgvector - PostgreSQL vector extension

Authentication

Authentication providers integrate with Mastra’s server authentication system:
  • Clerk - Modern user management and authentication
  • Auth0 - Enterprise identity platform
  • Supabase Auth - Open-source auth with database integration
  • better-auth - Self-hosted authentication framework

Server Adapters

Server adapters enable Mastra to run on different web frameworks:
  • Hono - Lightweight, fast web framework
  • Express - Battle-tested Node.js framework

Plugin Architecture

Mastra uses dependency injection to compose integrations:
import { Mastra } from '@mastra/core';
import { PostgresStore } from '@mastra/pg';
import { PgVector } from '@mastra/pg';
import { MastraAuthClerk } from '@mastra/auth-clerk';
import { MastraServer } from '@mastra/hono';
import { Hono } from 'hono';

const mastra = new Mastra({
  storage: new PostgresStore({
    id: 'my-storage',
    connectionString: process.env.DATABASE_URL!,
  }),
  vectors: {
    embeddings: new PgVector({
      id: 'embeddings',
      connectionString: process.env.DATABASE_URL!,
    }),
  },
  server: {
    auth: new MastraAuthClerk(),
  },
});

const app = new Hono();
const server = new MastraServer({ mastra, app });

Common Patterns

Multiple Storage Domains

You can use different storage backends for different purposes:
const mastra = new Mastra({
  // Use LibSQL for local development
  storage: new LibSQLStore({
    id: 'local',
    url: 'file:./dev.db',
  }),
  // Use Postgres for vector operations
  vectors: {
    embeddings: new PgVector({
      id: 'vectors',
      connectionString: process.env.DATABASE_URL!,
    }),
  },
});

Environment-Based Configuration

Configure integrations based on environment:
const storage =
  process.env.NODE_ENV === 'production'
    ? new PostgresStore({
        id: 'prod',
        connectionString: process.env.DATABASE_URL!,
      })
    : new LibSQLStore({
        id: 'dev',
        url: 'file:./dev.db',
      });

const mastra = new Mastra({ storage });

Next Steps

Storage

Set up persistent storage for workflows and memory

Vector Stores

Enable semantic search with vector databases

Authentication

Secure your Mastra server with auth providers

Server Adapters

Deploy Mastra on your preferred web framework

Build docs developers (and LLMs) love