mirror of
https://github.com/mastra-ai/mastra.git
synced 2026-11-17 08:44:46 +00:00
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> |
History
|
|
|---|---|---|
| .. | ||
| src | ||
| CHANGELOG.md | ||
| lint-staged.config.js | ||
| oxlint.config.ts | ||
| package.json | ||
| README.md | ||
| tsconfig.build.json | ||
| tsconfig.json | ||
| tsdown.config.ts | ||
| turbo.json | ||
| vitest.config.ts | ||
@mastra/auth-better-auth
@mastra/auth-better-auth connects a Better Auth instance to Mastra's server authentication layer. Use it when you want a self-hosted, TypeScript-first authentication system that you control instead of relying on a hosted identity provider.
Installation
npm install @mastra/auth-better-auth
npm install better-auth
Usage
Create a Better Auth instance with your database configuration, then register its Mastra adapter under server.auth.
import { MastraAuthBetterAuth } from '@mastra/auth-better-auth';
import { Mastra } from '@mastra/core/mastra';
import { betterAuth } from 'better-auth';
const auth = betterAuth({
database: {
provider: 'postgresql',
url: process.env.DATABASE_URL!,
},
emailAndPassword: {
enabled: true,
},
});
export const mastra = new Mastra({
server: {
auth: new MastraAuthBetterAuth({ auth }),
},
});
Documentation
Changelog
See the package changelog for version history and release notes.
Support
We have an open community Discord. Come and say hello and let us know if you have any questions or need any help getting things running.