Options
List of all the available options for configuring Better Auth. See Better Auth Options.
Prop | Type | Default |
---|---|---|
appName | string | "Better Auth" |
baseURL | string | - |
basePath | string | "/api/auth" |
secret | string | - |
database | PostgresPool | MysqlPool | Database | Dialect | AdapterInstance | { dialect: Dialect; type: KyselyDatabaseType; generateId?: false | ... 1 more ... | undefined; } | { ...; } | - |
secondaryStorage | SecondaryStorage | - |
emailVerification | { sendVerificationEmail?: ((data: { user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; }; url: string; token: string; }, request?: Request | undefined) => Promise<...>) | undefined; sendOnSignUp?: boolean | undefined; autoSign... | - |
emailAndPassword | { enabled: boolean; requireEmailVerification?: boolean | undefined; maxPasswordLength?: number | undefined; minPasswordLength?: number | undefined; sendResetPassword?: ((data: { user: { ...; }; url: string; token: string; }, request?: Request | undefined) => Promise<...>) | undefined; resetPasswordTokenExpiresIn?: n... | - |
socialProviders | Partial<Record<"apple" | "discord" | "facebook" | "github" | "microsoft" | "google" | "spotify" | "twitch" | "twitter" | "dropbox" | "linkedin" | "gitlab", Prettify<AppleOptions & { ...; }>>> | ... 10 more ... | Partial<...> | - |
plugins | BetterAuthPlugin[] | - |
user | { modelName?: string | undefined; fields?: Partial<Record<"email" | "emailVerified" | "name" | "createdAt" | "updatedAt" | "image", string>> | undefined; additionalFields?: { ...; } | undefined; changeEmail?: { ...; } | undefined; } | - |
session | { modelName?: string | undefined; fields?: Partial<Record<"userId" | "expiresAt" | "ipAddress" | "userAgent", string>> | undefined; expiresIn?: number | undefined; updateAge?: number | undefined; additionalFields?: { ...; } | undefined; storeSessionInDatabase?: boolean | undefined; cookieCache?: { ...; } | undefined... | - |
account | { modelName?: string | undefined; fields?: Partial<Record<"userId" | "expiresAt" | "providerId" | "accountId" | "accessToken" | "refreshToken" | "idToken" | "password", string>> | undefined; accountLinking?: { ...; } | undefined; } | - |
verification | { modelName?: string | undefined; fields?: Partial<Record<"createdAt" | "expiresAt" | "value" | "identifier", string>> | undefined; } | - |
trustedOrigins | string[] | - |
rateLimit | { enabled?: boolean | undefined; window?: number | undefined; max?: number | undefined; customRules?: { [key: string]: { window: number; max: number; }; } | undefined; storage?: "memory" | "database" | "secondary-storage" | undefined; modelName?: string | undefined; fields?: Record<...> | undefined; customStorage?: ... | - |
advanced | { ipAddress?: { ipAddressHeaders?: string[] | undefined; disableIpTracking?: boolean | undefined; } | undefined; useSecureCookies?: boolean | undefined; disableCSRFCheck?: boolean | undefined; crossSubDomainCookies?: { ...; } | undefined; cookies?: { ...; } | undefined; defaultCookieAttributes?: CookieOptions | unde... | - |
logger | Logger | - |
databaseHooks | { user?: { create?: { before?: ((user: { id: string; email: string; emailVerified: boolean; name: string; createdAt: Date; updatedAt: Date; image?: string | null | undefined; }) => Promise<...>) | undefined; after?: ((user: { ...; }) => Promise<...>) | undefined; } | undefined; update?: { ...; } | undefined; } | und... | - |
onAPIError | { throw?: boolean | undefined; onError?: ((error: unknown, ctx: AuthContext) => void | Promise<void>) | undefined; } | - |