Auth

Auth

better-auth server config, client hooks, and auth UI modules with demo mode.

The auth workspace package wraps better-auth with Feature Kits form patterns, card layouts, and sign-out affordances. The docs playground runs in demo mode (in-memory database, no GitHub or database environment variables).

When to use it

ExportUse when
SignInForm / SignUpFormEmail/password flows with Zod + FormKit
AuthProviders / GitHubSignInButtonSocial sign-in row above the form
AuthCardLayoutConsistent auth page chrome
useSession / signOutClient session from better-auth
auth (auth/server)Next.js route handler (/api/auth/[...all])

Installation

Registry CLI

Requires a one-time components.json registry entry for @feature-kit/auth.

pnpm dlx shadcn@latest add https://feature-kits.vercel.app/r/auth.json

Namespaced: npx shadcn@latest add @feature-kit/auth

Manual installation

Monorepo consumers can depend on workspace:* packages instead of the registry CLI.

pnpm add auth form ui

Dependencies

// apps/your-app/package.json
"dependencies": {
    "auth": "workspace:*"
    "form": "workspace:*"
    "ui": "workspace:*"
}

Transpile (Next.js)

// next.config.ts
transpilePackages: ["auth", "form", "ui"]

Import

import { SignInForm, AuthCardLayout } from "@/lib/feature-kit/auth"
import { auth } from "@/lib/feature-kit/auth/server"

Mount the better-auth handler once in your app. The playground uses demo mode when DATABASE_URL and GitHub credentials are absent.

API route

// apps/web/src/app/api/auth/[...all]/route.ts
import { auth } from "auth/server"
import { toNextJsHandler } from "better-auth/next-js"

export const { GET, POST } = toNextJsHandler(auth)

Demo mode

auth/server uses the memory adapter and a fixed development secret when DATABASE_URL or GitHub OAuth credentials are missing. Sessions reset on serverless cold starts. Set AUTH_DEMO_MODE=false and provide production secrets to disable demo defaults.

Usage

Sign in

Sign in
Email and password with GitHub provider button.

New here? Create an account

Forgot your password? Reset password

Sign out

Use SignOutButton, SignOutIconButton, or SignOutDropdownMenuItem in headers and account menus. Pair with DashboardAccountMenu from layout.

API reference

AuthSchema

Zod input objects for SIGN_IN, SIGN_UP, FORGOT_PASSWORD, RESET_PASSWORD, and VERIFY_EMAIL. Import from auth/schema when you need types without UI.

SignInForm props
PropTypeDescription
redirectTostringPost-login navigation target.
Live preview with sample data in the docs. Sign up previewLive preview with sample data in the docs. Forgot passwordLive preview with sample data in the docs. Verify email

On this page