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.

MastraAuthSupabase Class

The MastraAuthSupabase class provides authentication for Mastra using Supabase Auth. It verifies incoming requests using Supabase's authentication system and integrates with the Mastra server using the experimental_auth option.

Usage exampleDirect link to Usage example

src/mastra/index.ts
import { Mastra } from "@mastra/core/mastra";
import { MastraAuthSupabase } from "@mastra/auth-supabase";

export const mastra = new Mastra({
// ..
server: {
experimental_auth: new MastraAuthSupabase({
url: process.env.SUPABASE_URL,
anonKey: process.env.SUPABASE_ANON_KEY,
}),
},
});

Constructor parametersDirect link to Constructor parameters

url?:

string
= process.env.SUPABASE_URL
The URL of your Supabase project. Can be found in your Supabase project settings.

anonKey?:

string
= process.env.SUPABASE_ANON_KEY
The anonymous/public key for your Supabase project. Used for client-side authentication.

name?:

string
Custom name for the auth provider instance.

authorizeUser?:

(user: User, request: HoneRequest) => Promise<boolean> | boolean
Custom authorization function to determine if a user should be granted access. Called after token verification. By default, checks the 'isAdmin' column in the 'users' table.

MastraAuthSupabase

On this page