Authentication
OAuth login/logout with Better Auth and Reopt OAuth provider.
Session Status
Not authenticated
lib/auth.ts
import { betterAuth } from "better-auth";
import { nextCookies } from "better-auth/next-js";
import { createReoptBetterAuth } from "@reopt-ai/brandapp-sdk/better-auth";
const reopt = createReoptBetterAuth({
clientId: process.env.BRANDAPP_CLIENT_ID!,
clientSecret: process.env.BRANDAPP_CLIENT_SECRET!,
brandappId: process.env.BRANDAPP_ID!,
});
export const auth = betterAuth({
baseURL: process.env.BETTER_AUTH_URL ?? "http://localhost:3000",
secret: process.env.BETTER_AUTH_SECRET,
trustedOrigins: ["http://localhost:3000"],
database: reopt.database,
plugins: [reopt.oauth, nextCookies()],
});