Skip to content

Instantly share code, notes, and snippets.

@PhantomKnight287
Created May 18, 2025 13:13
Show Gist options
  • Select an option

  • Save PhantomKnight287/4a9dacf98ca62d49368fdfc9cc282ffe to your computer and use it in GitHub Desktop.

Select an option

Save PhantomKnight287/4a9dacf98ca62d49368fdfc9cc282ffe to your computer and use it in GitHub Desktop.
import { betterAuth, logger } from "better-auth";
import {
admin,
anonymous,
apiKey,
bearer,
captcha,
createAuthMiddleware,
emailOTP,
haveIBeenPwned,
magicLink,
multiSession,
oneTimeToken,
openAPI,
organization,
phoneNumber,
twoFactor,
username,
} from "better-auth/plugins";
import { db } from "./db.js";
import { expo } from "@better-auth/expo";
import { passkey } from "better-auth/plugins/passkey";
export const auth = betterAuth({
emailAndPassword: {
enabled: true,
},
plugins: [
bearer(),
openAPI({}),
expo(),
twoFactor(),
username(),
anonymous(),
phoneNumber({
sendOTP(data) {
console.log(data);
},
}),
magicLink({
async sendMagicLink(data, request) {
console.log(data, request);
},
}),
emailOTP({
async sendVerificationOTP(data, request) {
console.log(data, request);
},
}),
passkey(),
admin(),
apiKey(),
organization(),
oneTimeToken({}),
],
socialProviders: {
github: {
clientId: process.env.GITHUB_CLIENT_ID!,
clientSecret: process.env.GITHUB_CLIENT_SECRET!,
},
},
database: db,
trustedOrigins: [
"bac://fyi.procrastinator.better-auth-client",
"bac://",
"http://localhost:3000",
],
hooks: {},
user: {
additionalFields: {
premium: {
type: "boolean",
defaultValue: false,
required: false,
},
},
},
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment