Configuration Options
Configure the Payload Better Auth Plugin
Configuration Options
The plugin accepts the following configuration options:
BetterAuthPluginOptions
type BetterAuthPluginOptions = {
betterAuth?: Omit<BetterAuthOptions, 'database'>;
extendsCollections?: {
[K in CollectionSlug]?: CollectionConfigExtend<K>;
};
logs?: false | 'fatal' | 'error' | 'warn' | 'info' | 'debug' | 'trace';
}Better Auth Config
The betterAuth object configures core Better Auth settings:
{
appName: 'My App', // Used for 2FA and other features
baseURL: 'https://myapp.com', // Optional - defaults to the server url
basePath: '/api/auth', // Optional - defaults to '/api/auth'
secret: process.env.BETTER_AUTH_SECRET, // Optional - defaults to process.env.BETTER_AUTH_SECRET
}Extending Collections
You can extend the default collections with additional fields:
{
extendsCollections: {
user: {
fields: [
{
name: 'nickname',
type: 'text',
},
{
name: 'posts',
type: 'relationship',
relationTo: 'posts',
hasMany: true,
},
],
},
},
}Logging
Configure logging levels for debugging:
{
logs: 'debug' // Options: false | 'trace' | 'debug' | 'info' | 'warn' | 'error'
}