Deploy with a web framework

Trust: ★★★☆☆ (0.90) · 0 validations · developer_reference

Published: 2026-05-10 · Source: crawler_authoritative

Tình huống

Guide for deploying Mastra when integrated with Next.js or Astro web frameworks, targeting developers who want to deploy their Mastra AI applications to cloud platforms.

Insight

Mastra deployments integrate with your web framework using the framework’s standard deployment process. A critical warning applies to all cloud deployments: LibSQLStore must be removed from Mastra configuration because it requires filesystem access and is incompatible with serverless platforms.

For Next.js deployments to Vercel, the next.config.ts must include the serverExternalPackages configuration to prevent Vercel from bundling Mastra packages as serverless functions. The import uses the NextConfig type from ‘next’, and the config array [‘@mastra/*’] ensures all Mastra packages are excluded from serverless bundling.

For Astro deployments, two adapter options are documented: the Vercel adapter (@astrojs/vercel) and Netlify adapter (@astrojs/netlify). Both require setting the output configuration to ‘server’ to enable server-side rendering, which is necessary for Mastra to function correctly. The adapters are imported from their respective packages and configured via the defineConfig utility from Astro.

Hành động

To deploy with Next.js on Vercel:

  1. Import NextConfig type from ‘next’
  2. Add serverExternalPackages with [‘@mastra/*’] to the next.config.ts config object
  3. Export the default config

To deploy with Astro on Vercel:

  1. Install @astrojs/vercel package
  2. Import vercel from ‘@astrojs/vercel’
  3. Add adapter: vercel() and output: ‘server’ to astro.config.mjs

To deploy with Astro on Netlify:

  1. Install @astrojs/netlify package
  2. Import netlify from ‘@astrojs/netlify’
  3. Add adapter: netlify() and output: ‘server’ to astro.config.mjs

Before deploying to any cloud platform, remove LibSQLStore from your Mastra storage configuration to avoid runtime errors.

Kết quả

Mastra deploys alongside your web application using the framework’s deployment infrastructure. For Vercel and Netlify, the adapters enable proper server-side execution required for Mastra to function.

Điều kiện áp dụng

LibSQLStore must be removed when deploying to any cloud platform or serverless environment. Server-side rendering (output: ‘server’) is required for Astro deployments. Next.js on Vercel requires Node.js runtime configuration.


Nội dung gốc (Original)

Deploy with a web framework

When Mastra is integrated with a web framework, it deploys alongside your application using the framework’s standard deployment process. Follow the instructions below to ensure your Mastra integration deploys correctly.

Warning: If you’re deploying to a cloud provider, remove any usage of LibSQLStore from your Mastra configuration. LibSQLStore requires filesystem access and isn’t compatible with serverless platforms.

Integration guides:

With Next.js on Vercel

If you’ve integrated Mastra with Next.js by following our guide and plan to deploy to Vercel, add serverExternalPackages: ["@mastra/*"] to your next.config.ts:

import type { NextConfig } from 'next'
 
const nextConfig: NextConfig = {
  serverExternalPackages: ['@mastra/*'],
}
 
export default nextConfig

With Astro on Vercel

If you’ve integrated Mastra with Astro by following our guide and plan to deploy to Vercel, add the Vercel adapter and server output to your astro.config.mjs:

import { defineConfig } from 'astro/config'
import vercel from '@astrojs/vercel'
 
export default defineConfig({
  adapter: vercel(),
  output: 'server',
})

With Astro on Netlify

If you’ve integrated Mastra with Astro by following our guide and plan to deploy to Netlify, add the Netlify adapter and server output to your astro.config.mjs:

import { defineConfig } from 'astro/config'
import netlify from '@astrojs/netlify'
 
export default defineConfig({
  adapter: netlify(),
  output: 'server',
})

Liên kết

Xem thêm: