
A Better Auth database adapter that uses Strapi as the database backend
released May 9, 2026
npm install @strapi-community/plugin-better-authA Better Auth database adapter that uses Strapi as the database backend. This package allows you to integrate Better Auth's authentication system with your Strapi application seamlessly.
[!CAUTION]
This plugin is in BETA state. It is by no means considered stable and should not be used in production. If you want to contribute to it's development, please contact any of the maintainers.
You need to be running Strapi 5.45.0 or higher to use this plugin.
npm install better-auth @strapi-community/plugin-better-auth
# or
yarn add better-auth @strapi-community/plugin-better-auth
# or
pnpm add better-auth @strapi-community/plugin-better-authCreate the Better Auth config file and add the following content.
// config/better-auth.ts
import { betterAuth } from "better-auth";
import { strapiAdapter } from '@strapi-community/plugin-better-auth';
const auth = () => betterAuth({
database: strapiAdapter(),
trustedOrigins: ['http://localhost:3000'],
advanced: {
database: {
generateId: 'serial',
},
},
});
export default auth;Run the content type generation command to bootstrap the default content types.
npx auth@latest generate --config config/better-auth.tsTip: Every time you install a new Better Auth plugin, you have to run this command again.
Call the Better Auth API from your front-end:
// In your React/Vue/Svelte app
import { createAuthClient } from 'better-auth/react'; // or /vue, /svelte
const authClient = createAuthClient({
baseURL: 'http://localhost:1337/api/auth',
});
// Sign up
await authClient.signUp.email({
email: 'user@example.com',
password: 'password123',
name: 'John Doe',
});Use the Better Auth session to authenticate your users in custom Strapi controllers.
import { auth } from '@/lib/auth.ts';
// In a Strapi controller
export default {
async customMethod(ctx) {
// Use Better Auth API methods
const session = await auth.api.getSession({
headers: ctx.request.headers,
});
if (session) {
// User is authenticated
console.log('User:', session.user);
}
}
}Any Better Auth plugin may be used with Strapi + Better Auth. Some plugins require you to run the generate CLI in order to make the required schema changes. To do that you have to manually specify the location of the Better Auth config file.
npx auth@latest generate --config config/better-auth.tsSee the LICENSE file for licensing information.
Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.
Submit
