// cSpell:ignore SVGE SVGMFHN Galf "use client"; import Link from "next/link"; import type { ReactNode } from "react"; import { Icons as frameworkIcons } from "@/components/docs/icons"; import { DynamicCodeBlock } from "@/components/ui/dynamic-code-block"; export const providerIcons: Record ReactNode> = { Google: () => ( ), GitHub: () => ( ), Apple: () => ( ), Microsoft: () => ( ), Discord: () => ( ), Slack: () => ( ), Twitter: () => ( ), Facebook: () => ( ), LinkedIn: () => ( ), GitLab: () => ( ), Twitch: () => ( ), Spotify: () => ( ), Figma: () => ( ), Notion: () => ( ), Atlassian: () => ( ), HuggingFace: () => ( ), Reddit: () => ( ), TikTok: () => ( ), PayPal: () => ( ), Dropbox: () => ( ), Zoom: () => ( ), Vercel: () => ( ), Linear: () => ( ), Kick: () => ( ), Kakao: () => ( ), Line: () => ( ), VK: () => ( ), Naver: () => ( ), Bitbucket: () => ( ), Trello: () => ( ), Steam: () => ( ), Coinbase: () => ( ), Patreon: () => ( ), Okta: () => ( ), Yahoo: () => ( ), Adobe: () => ( ), Polar: () => ( ), Roblox: () => ( ), Salesforce: () => ( ), Stripe: () => ( ), }; export const socialProviders = [ "Google", "GitHub", "Apple", "Microsoft", "Discord", "Slack", "Twitter", "Facebook", "LinkedIn", "GitLab", "Twitch", "Spotify", "Figma", "Notion", "Atlassian", "Salesforce", "HuggingFace", "Roblox", "Reddit", "TikTok", "PayPal", "Dropbox", "Zoom", "Vercel", "Linear", "Kick", "Kakao", "Line", "VK", "Naver", "Polar", "Bitbucket", "Trello", "Steam", "Yahoo", "Coinbase", "Patreon", "Stripe", "Adobe", "Okta", ]; export const plugins = [ { name: "Two Factor", category: "auth" }, { name: "Passkey", category: "auth" }, { name: "Magic Link", category: "auth" }, { name: "Email OTP", category: "auth" }, { name: "Username", category: "auth" }, { name: "One Tap", category: "auth" }, { name: "Phone Number", category: "auth" }, { name: "Anonymous", category: "auth" }, { name: "Bearer", category: "auth" }, { name: "Generic OAuth", category: "auth" }, { name: "One Time Token", category: "auth" }, { name: "SIWE", category: "auth" }, { name: "Organization", category: "org" }, { name: "Admin", category: "org" }, { name: "Multi Session", category: "org" }, { name: "API Key", category: "org" }, { name: "SSO", category: "enterprise" }, { name: "OIDC Provider", category: "enterprise" }, { name: "SCIM", category: "enterprise" }, { name: "OAuth Proxy", category: "enterprise" }, { name: "JWT", category: "security" }, { name: "HIBP", category: "security" }, { name: "Captcha", category: "security" }, { name: "Stripe", category: "integration" }, { name: "Polar", category: "integration" }, { name: "Open API", category: "integration" }, { name: "Dub", category: "integration" }, { name: "Autumn", category: "integration" }, { name: "Dodo Payments", category: "integration" }, { name: "Creem", category: "integration" }, { name: "MCP", category: "ai" }, { name: "Device Auth", category: "auth" }, { name: "Last Login", category: "auth" }, ]; export const categoryLabels: Record = { auth: "Authentication", org: "Organization", enterprise: "Enterprise", security: "Security", integration: "Integration", ai: "AI", }; const _categoryColors: Record = { auth: "text-violet-500/50 dark:text-violet-400/40", org: "text-sky-500/50 dark:text-sky-400/40", enterprise: "text-amber-500/50 dark:text-amber-400/40", security: "text-red-500/50 dark:text-red-400/40", integration: "text-emerald-500/50 dark:text-emerald-400/40", ai: "text-pink-500/50 dark:text-pink-400/40", }; const dbDrivers = [ { name: "PostgreSQL", icon: () => ( ), }, { name: "MySQL", icon: () => ( ), }, { name: "SQLite", icon: () => ( ), }, { name: "MongoDB", icon: () => ( ), }, { name: "LibSQL", icon: () => ( ), }, ]; const ormAdapters = [ { name: "Prisma", icon: () => ( ), }, { name: "Drizzle", icon: () => ( ), }, ]; const dbSnippets: Record = { PostgreSQL: `import { betterAuth } from "better-auth" import { Pool } from "pg" const pool = new Pool({ connectionString: process.env.DATABASE_URL, }) export const auth = betterAuth({ database: pool, emailAndPassword: { enabled: true, }, socialProviders: { github: { clientId: process.env.GITHUB_CLIENT_ID!, clientSecret: process.env.GITHUB_CLIENT_SECRET!, }, }, })`, MySQL: `database: new Pool({ connectionString: process.env.DATABASE_URL, })`, SQLite: `database: new Database("sqlite.db")`, MongoDB: `database: mongodbAdapter(db)`, LibSQL: `database: new Pool({ connectionString: process.env.DATABASE_URL, })`, Prisma: `database: prismaAdapter(prisma, { provider: "postgresql", })`, Drizzle: `database: drizzleAdapter(db, { provider: "pg", })`, }; export const serverCode = `import { betterAuth } from "better-auth" export const auth = betterAuth({ emailAndPassword: { enabled: true, }, socialProviders: { google: { clientId: process.env.GOOGLE_CLIENT_ID!, clientSecret: process.env.GOOGLE_CLIENT_SECRET!, }, github: { clientId: process.env.GITHUB_CLIENT_ID!, clientSecret: process.env.GITHUB_CLIENT_SECRET!, }, }, plugins: [ twoFactor(), passkey(), organization(), ], })`; export const clientCode = `import { createAuthClient } from "better-auth/react" export const authClient = createAuthClient({ plugins: [ twoFactorClient(), passkeyClient(), organizationClient(), ], })`; export function ServerClientTabs() { return (
auth.ts
); } const allDbs = [...dbDrivers, ...ormAdapters]; export function DatabaseSection() { const pg = allDbs.find((d) => d.name === "PostgreSQL")!; const others = allDbs.filter((d) => d.name !== "PostgreSQL"); return (
{/* PostgreSQL — intentionally larger feature tile */}
{pg.icon()} {pg.name}
{/* Other databases */} {others.map((db) => (
{db.icon()} {db.name}
))}
); } export function SocialProvidersSection() { const providerBadges: Record = { Cognito: "CG", Railway: "RW", Paybin: "PB", WeChat: "WC", }; return (
{socialProviders.length}+ Providers
{socialProviders.map((provider) => { const Icon = providerIcons[provider]; return ( {Icon ? ( Icon() ) : ( {providerBadges[provider] ?? provider.slice(0, 2).toUpperCase()} )} {provider} ); })}
); } const featuredIcons: Record ReactNode> = { "Next.js": () => ( ), TanStack: () => ( ), }; const featured = [ { name: "Next.js", icon: "nextJS", href: "/docs/integrations/next", snippet: "export { GET, POST } from '@/auth'", }, { name: "TanStack", icon: "tanstack", href: "/docs/integrations/tanstack", snippet: "createServerFileRoute().createRouter(auth)", }, { name: "Nuxt", icon: "nuxt", href: "/docs/integrations/nuxt", snippet: "export default defineNuxtPlugin(auth)", }, { name: "SvelteKit", icon: "svelteKit", href: "/docs/integrations/svelte-kit", snippet: "export const handle = auth.handle", }, { name: "Astro", icon: "astro", href: "/docs/integrations/astro", snippet: "export const { GET, POST } = auth", }, { name: "Hono", icon: "hono", href: "/docs/integrations/hono", snippet: "app.on(['GET','POST'], auth.handler)", }, ] as const; const moreFrameworks = [ { name: "React", icon: "react", href: "/docs/integrations/react" }, { name: "Vue", icon: "vue", href: "/docs/integrations/vue" }, { name: "Remix", icon: "remix", href: "/docs/integrations/remix" }, { name: "Solid Start", icon: "solidStart", href: "/docs/integrations/solid-start", }, { name: "Express", icon: "express", href: "/docs/integrations/express" }, { name: "Fastify", icon: "fastify", href: "/docs/integrations/fastify" }, { name: "NestJS", icon: "nestJS", href: "/docs/integrations/nestjs" }, { name: "Elysia", icon: "elysia", href: "/docs/integrations/elysia" }, { name: "Nitro", icon: "nitro", href: "/docs/integrations/nitro" }, { name: "Expo", icon: "expo", href: "/docs/integrations/expo" }, { name: "Lynx", icon: "lynx", href: "/docs/integrations/lynx" }, { name: "Encore", icon: "encore", href: "/docs/integrations/encore" }, { name: "Convex", icon: "convex", href: "/docs/integrations/convex" }, ] as const; export function IntegrationsSection() { return (
{/* Featured integrations */}
{featured.map((fw) => { const customIcon = featuredIcons[fw.name]; const fallbackIcon = frameworkIcons[fw.icon as keyof typeof frameworkIcons]; const renderIcon = customIcon || fallbackIcon; return ( {renderIcon?.()} {fw.name} {fw.snippet} ); })}
{/* More frameworks */}

+ {moreFrameworks.length} more

{moreFrameworks.map((fw) => { const iconFn = frameworkIcons[fw.icon as keyof typeof frameworkIcons]; return ( {iconFn?.()} {fw.name} ); })}
); } export function PluginEcosystem() { const half = Math.ceil(plugins.length / 2); const row1 = plugins.slice(0, half); const row2 = plugins.slice(half); return (
Plugin Ecosystem browse all →
{/* Row 1 — scrolls left */}
{[...row1, ...row1].map((plugin, i) => ( {plugin.name} {categoryLabels[plugin.category]} ))}
{/* Row 2 — scrolls right */}
{[...row2, ...row2].map((plugin, i) => ( {plugin.name} {categoryLabels[plugin.category]} ))}
{/* Side fades */}
); } export function AiNativeSection() { const steps = [ { label: "mcp", text: "Connected to better-auth docs" }, { label: "skill", text: "better-auth/add-provider → google" }, { label: "skill", text: "better-auth/add-plugin → two-factor" }, { label: "write", text: "lib/auth.ts", lines: 14 }, { label: "done", text: "Google OAuth + 2FA configured" }, ]; const mcpClients = [ { name: "Claude Code", cmd: "claude mcp add better-auth" }, { name: "Cursor", cmd: "cursor mcp add better-auth" }, { name: "VS Code", cmd: "code --add-mcp better-auth" }, ]; return (
AI Native

Your auth lives in{" "} your codebase {" "} — so AI can configure it. Ships with{" "} MCP server ,{" "} Claude Code skills , and{" "} Cursor rules .

{/* Prompt line */}
Add Google login and 2FA to my app
{/* Steps */}
{steps.map((step) => (
{step.label} {step.text} {"lines" in step && typeof step.lines === "number" && ( +{step.lines} )} {step.label === "done" && ( )}
))}
{/* MCP clients */}
{mcpClients.map((mc) => (

{mc.name}

{mc.cmd}
))}
); }