Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
171 commits
Select commit Hold shift + click to select a range
0afaa7e
fix(web): add index signature to VorlageItem for Template compatibility
Movm Mar 27, 2026
1724257
fix(security): resolve remaining CodeQL alerts across all severity le…
Movm Mar 27, 2026
5cb9054
feat(api): add vision/image analysis support to chat pipeline
Movm Mar 28, 2026
1d36c79
feat(api): use Docling as primary document extractor for chat attachm…
Movm Mar 28, 2026
72587f2
fix(api): fall back to Mistral when REGOLO_API_KEY is not configured
Movm Mar 28, 2026
bd0f66f
refactor(web): restyle tool buttons and remove groups section from wo…
Movm Mar 28, 2026
30d55d5
fix(ci): add retry logic and secret validation to briefing agents wor…
Movm Mar 28, 2026
25f546b
refactor(ci): extract social-media sync into dedicated workflow
Movm Mar 28, 2026
d32dd30
feat(ui): add square aspect variant to VideoCard component
Movm Mar 28, 2026
4e0385c
feat(web): integrate reels into recently created section with square …
Movm Mar 28, 2026
ef1833e
fix(web): remove footer from reel cards to preserve square aspect ratio
Movm Mar 28, 2026
294a13d
feat(ui): add mobile tap-to-play and separate title navigation to Vid…
Movm Mar 28, 2026
8f89182
refactor(api): remove deprecated auto-search feature from backend
Movm Mar 28, 2026
e28682b
refactor(web): remove auto-search and auto-save UI and stores
Movm Mar 28, 2026
933f5e2
refactor(web): remove dead generator modes, unused toggles, and simpl…
Movm Mar 28, 2026
386a5cc
feat(web): simplify Dein Grünerator wizard to 2-step locale-aware flow
Movm Mar 28, 2026
85b1a5d
feat(web): promote chat settings to standalone /dein-gruenerator route
Movm Mar 28, 2026
3ee3d4f
feat(api,web): add Grüne API test page for exploring platform endpoints
Movm Mar 28, 2026
986c3bc
chore(web): remove orphaned sharepic components, GeneratorOutput, and…
Movm Mar 28, 2026
93c46fd
fix(api): fix TypeScript error in Grüne API test controller params type
Movm Mar 28, 2026
0eed082
feat(web): redesign Dein Grünerator for multiple roles and unified pr…
Movm Mar 28, 2026
cd6265e
refactor(api,web): simplify Sonstige modes to single input and improv…
Movm Mar 28, 2026
bf2d24f
feat(api): inject user profile instructions into all chat modes
Movm Mar 28, 2026
a19b59c
feat(web): add per-role AI-generated system prompts to Dein Grünerator
Movm Mar 28, 2026
4ab1e7b
refactor(web): remove personal instructions from profile, clean up ro…
Movm Mar 28, 2026
5fd2917
feat(chat): add role selection to chat overview and mode switcher
Movm Mar 28, 2026
abe105d
feat(ui,web): add SmartInput autocomplete component, use for Bundesla…
Movm Mar 28, 2026
044ef00
fix(ui): use plain input in SmartInput to fix typing issue
Movm Mar 28, 2026
eb97696
fix(ui): fix SmartInput typing and auto-advance on selection
Movm Mar 28, 2026
9cb523e
feat(web): move role instructions to dedicated wizard step with skip …
Movm Mar 28, 2026
2f9bb13
fix(web): remove duplicate TooltipProvider and add conditional NavToo…
Movm Mar 28, 2026
5126627
fix(web): replace Radix Tooltips with title attrs in profile dropdown…
Movm Mar 28, 2026
0e5e868
fix(web): memoize NotificationList component
Movm Mar 28, 2026
ac5fb3d
fix(web): stabilize useOptimizedAuth and useBetaFeatures returns with…
Movm Mar 28, 2026
7ac25c4
feat(ui): add LiteTooltip component, use in profile dropdown
Movm Mar 28, 2026
665b24f
fix(web): eliminate avatar #1 flicker by seeding profile in /auth/ini…
Movm Mar 28, 2026
c742dd7
fix(web): decouple useBetaFeatures from useOptimizedAuth to prevent r…
Movm Mar 28, 2026
5cb2701
fix(chat): skip WebSocket collaboration when not in thread view
Movm Mar 28, 2026
194d320
fix(web): replace useOptimizedAuth with useAuthStore selector in with…
Movm Mar 28, 2026
dd347ed
fix(ui): defer entire DropdownMenu mount in CardActionsMenu until fir…
Movm Mar 28, 2026
39af05e
fix(web,chat): remove unnecessary useEffects, stabilize GlobalChatPro…
Movm Mar 28, 2026
682038d
refactor(web): replace useOptimizedAuth with direct useAuthStore sele…
Movm Mar 28, 2026
04584f9
refactor(web): replace remaining useLazyAuth/useOptimizedAuth in Inli…
Movm Mar 28, 2026
c69d0a0
feat(web): add why-did-you-render for dev, tune notification query cache
Movm Mar 28, 2026
9d96868
fix(web): remove broken wdyr import, package has monorepo resolution …
Movm Mar 28, 2026
50eeee7
fix(web): skip NotificationList when no notifications, fix broken Pro…
Movm Mar 28, 2026
9c21bf0
fix(web): replace LiteTooltip with pure CSS tooltips in profile dropdown
Movm Mar 28, 2026
0715914
fix(web): add overflow-visible to profile dropdown for CSS tooltip vi…
Movm Mar 28, 2026
5f7222b
feat(api): add Better Auth database migration
Movm Mar 28, 2026
6a6d83e
feat(api): add Better Auth with Keycloak genericOAuth providers
Movm Mar 28, 2026
573521f
feat(shared): switch login providers to Better Auth OAuth flow
Movm Mar 28, 2026
1055e44
fix(web): use native title tooltips in profile dropdown (CSS tooltips…
Movm Mar 28, 2026
fcd6a06
feat(web): replace icon-only buttons with icon+label in profile dropdown
Movm Mar 28, 2026
49b5b7a
feat(web): show profile nav labels only on hover
Movm Mar 28, 2026
dfb3bc4
feat(api): add mobile token exchange plugin for Better Auth
Movm Mar 28, 2026
ed5649b
feat(mobile): add Keycloak direct OIDC auth via expo-auth-session
Movm Mar 28, 2026
ca86cbb
fix(web): revert to icon-only buttons in profile dropdown nav
Movm Mar 28, 2026
5abcaa6
refactor(api): remove Passport.js, express-session, and legacy auth
Movm Mar 28, 2026
171c66c
chore(api): remove passport, express-session, openid-client dependencies
Movm Mar 28, 2026
bef3fac
fix(api): replace req.session.id with req.user.id in edit context cache
Movm Mar 28, 2026
cf8c4d9
fix(api): clean up remaining req.session references
Movm Mar 28, 2026
550c8cd
fix(api): pass image attachments as Buffer instead of data: URL for A…
Movm Mar 28, 2026
42577bd
fix(api): convert remaining data: URL image parts to Buffer for AI SD…
Movm Mar 28, 2026
84ba80c
refactor(api): remove all as-any casts, add type-safe auth mapping
Movm Mar 28, 2026
932af3a
refactor: remove Grüne Jugend features and Igel Modus entirely
Movm Mar 28, 2026
b851c23
feat(web): add board card enhancements — comments, assignees, covers,…
Movm Mar 28, 2026
797f7e3
refactor(docs): convert 6 CSS files to Tailwind, remove docs/styles i…
Movm Mar 29, 2026
799ff96
feat(web): rebuild DocsPage with CardGrid, add AI presentation genera…
Movm Mar 29, 2026
6a2c82e
feat(api): add SlidesGraph LangGraph pipeline for AI presentation gen…
Movm Mar 29, 2026
a5c465b
chore: stage pre-existing uncommitted changes
Movm Mar 29, 2026
b97f308
Squashed 'services/presenton/' content from commit 3e469cb9
Movm Mar 29, 2026
37c3f01
Merge commit 'b97f308017afef4fe4168bf9f5717c40c5bb29fe' as 'services/…
Movm Mar 29, 2026
dee2f0d
feat(presenton): add Grünerator deployment config for Presenton
Movm Mar 29, 2026
9c0b11c
feat(presenton): add Keycloak auth middleware and edit button
Movm Mar 29, 2026
6e49258
refactor(presenton): switch auth from Keycloak to Better Auth JWT
Movm Mar 29, 2026
38d8786
feat(presenton): add better auth session validation + cross-subdomain…
Movm Mar 29, 2026
12b4bac
chore(presenton): update branding to Grünerator Slides
Movm Mar 29, 2026
135b784
fix(presenton): add better-auth dependency to Next.js package.json
Movm Mar 29, 2026
2829621
fix(presenton): use npm install instead of npm ci in Dockerfile
Movm Mar 29, 2026
1300981
fix(presenton): resolve startup errors for local deployment
Movm Mar 29, 2026
d50b8a7
feat(presenton): german translation + grünerator green branding
Movm Mar 29, 2026
e835e51
feat(docs): unified overview with documents, presentations, and boards
Movm Mar 29, 2026
31e4490
feat(scraper): add Berlin Wahlprogramm 2026 chapters to notebook
Movm Mar 29, 2026
362dd40
chore(notebook): change Berlin notebook icon to MdDiversity1
Movm Mar 29, 2026
58fbb57
docs(notebook): update Berlin notebook descriptions to include Wahlpr…
Movm Mar 29, 2026
38b3f12
fix(presenton): fix broken files, switch to du form
Movm Mar 29, 2026
b00ea88
refactor(docs): extract card components, add 3-dot menu to all card t…
Movm Mar 29, 2026
747081a
fix(presenton): escape inner quotes in Help.tsx German strings
Movm Mar 29, 2026
3358f5e
fix(presenton): translate remaining English, comment out non-Grünerat…
Movm Mar 29, 2026
599be30
feat(presenton): official B90/GRÜNE 2025 theme + PPTX template
Movm Mar 29, 2026
2f93cce
feat(presenton): b90/grüne slide templates with self-hosted fonts, re…
Movm Mar 29, 2026
e5b34e0
feat(notebook): brandenburg icon to PiFlowerLight, restrict to LTW2024
Movm Mar 29, 2026
b4dc986
fix(workplace): locale-aware notebooks + mobile-first grid layout
Movm Mar 29, 2026
7d8a2c1
fix(presenton): exclude _archive from docker build, add presenton dev…
Movm Mar 29, 2026
e2bcc96
feat(presenton): wire grünerator backend for text/image generation, n…
Movm Mar 29, 2026
c9aebc0
feat(presenton): replace all fonts with self-hosted raleway + pt sans
Movm Mar 29, 2026
b6fab23
chore(presenton): replace presenton icons with grünerator branding
Movm Mar 29, 2026
7a9ac5b
fix(presenton): replace purple branding with grünerator green, update…
Movm Mar 29, 2026
d909e7f
fix(presenton): set env vars directly for locked config, disable mixp…
Movm Mar 29, 2026
304c53d
refactor(api): migrate briefing agents to n8n, add content-sync endpoint
Movm Mar 29, 2026
e544108
refactor(docs): extract CreateNewMenu, memoize handlers, use Responsi…
Movm Mar 29, 2026
c378259
feat(web): add dedicated Nutzungsbedingungen page
Movm Mar 29, 2026
952eebc
refactor: replace Gladia with Regolo for audio/video transcription
Movm Mar 29, 2026
d090893
docs(documentation): add webinare page with training offerings
Movm Mar 29, 2026
adae717
fix(deps): pin loader-utils override to ^2.0.4
Movm Mar 29, 2026
01abf93
fix(docker): add packages/slides to API Dockerfile for SlidesGraph types
Movm Mar 29, 2026
c047644
feat(boards): add threaded comments with reactions, @mentions, and no…
Movm Mar 29, 2026
cae55d1
fix(slides): add .js extensions to schema imports for NodeNext compat
Movm Mar 29, 2026
e2cb56a
feat(docs): group documents by shared groups with section headers
Movm Mar 30, 2026
69e1830
fix(docker): add packages/slides to web Dockerfile and fix SPA caching
Movm Mar 30, 2026
c9a7637
fix(collab): add connection lifecycle logging for WebSocket debugging
Movm Mar 30, 2026
8c7a027
fix(collab): stop user object from triggering WebSocket reconnection
Movm Mar 30, 2026
8acd0f3
feat(layout): hide header and sidebar in immersive layout mode
Movm Mar 30, 2026
6f6dcac
fix(docs): add shadcn CSS variable bridge, fix share modal layout
Movm Mar 30, 2026
5e50806
fix(docs): only show red connection dot after 5s disconnect
Movm Mar 30, 2026
185567b
fix(docs): convert markdown to HTML when exporting content to docs
Movm Mar 30, 2026
f1840ad
fix(workplace): remove double data-URL prefix on generated images
Movm Mar 30, 2026
53e8020
refactor(slides): replace generic Presenton layouts with Grüne templates
Movm Mar 30, 2026
899622d
fix(docker): compile slides schemas in API Docker build
Movm Mar 31, 2026
5144981
fix(api): include stack trace and route in global error handler
Movm Mar 31, 2026
7dae21f
fix(auth): resolve zod v4 for @better-auth/core
Movm Mar 31, 2026
357174d
chore(deps): update dependencies within semver ranges
Movm Mar 31, 2026
b1adc63
style(docs): modernize documentation site with Mintlify-inspired design
Movm Mar 31, 2026
1f9bc2e
chore: extract services/remotion as standalone gitignored service
Movm Mar 31, 2026
3102fac
fix(db): run migrations on startup and fix nested transactions
Movm Mar 31, 2026
30a3ac9
chore(deps): update dependencies within semver ranges
Movm Mar 31, 2026
d19d2ec
fix(deps): regenerate lockfile for packages/collab dependency update
Movm Mar 31, 2026
c820f6b
fix(ci): trigger builds on pnpm-lock.yaml changes
Movm Mar 31, 2026
68169a4
fix(deps): downgrade axios to ^1.14.0 (1.14.1 yanked from npm)
Movm Mar 31, 2026
a71aa90
fix(db): point migration runner to correct directory
Movm Mar 31, 2026
41d88f6
fix(db): advisory lock for migrations, fix stale migration scripts
Movm Mar 31, 2026
ca6c62b
fix(db): use BEGIN/COMMIT per migration, pg_try_advisory_lock to skip…
Movm Mar 31, 2026
7ada2fa
fix(auth): catch Better Auth handler errors, redirect instead of 502
Movm Mar 31, 2026
e39644f
fix(nginx): increase proxy buffer size for OAuth callback headers
Movm Mar 31, 2026
3c155bc
fix(db): change collaborative_presentations.user_id from TEXT to UUID
Movm Mar 31, 2026
92cbb9b
feat(imagine): add model selector, save to recent activity, lightbox …
Movm Mar 31, 2026
0493d11
fix(hocuspocus): log cookie names for WebSocket auth debugging
Movm Mar 31, 2026
a7e6940
fix(hocuspocus): read __Secure- prefixed Better Auth session cookie
Movm Mar 31, 2026
8584a93
fix(hocuspocus): verify sessions via API instead of direct DB lookup
Movm Mar 31, 2026
068eeca
feat(docs): use litellm → regolo → mistral provider chain for docs AI
Movm Mar 31, 2026
40b40ce
fix(web): add missing Tailwind @source directives for shared packages
Movm Mar 31, 2026
0cbf81b
feat(chat): include sources section when exporting notebook responses…
Movm Mar 31, 2026
b32f62c
fix(voice): ensure TTS stream response closes after all sentences
Movm Mar 31, 2026
dfa4483
fix(docs): reduce top padding, center search, hide Präsentation menu …
Movm Mar 31, 2026
863e744
fix(web): restore sidebar and top spacing for scanner and transfer pages
Movm Mar 31, 2026
8e277f8
fix(api): cast JSONB ? operator params to text and add missing 'docs'…
Movm Mar 31, 2026
7dc86ef
refactor(ui): extract IconButton and IconButtonRow into packages/ui
Movm Mar 31, 2026
63260e7
refactor(scanner): simplify results UI and default to private OCR
Movm Mar 31, 2026
a633541
refactor(web): default transcription to private OCR with opt-in diari…
Movm Mar 31, 2026
9d356f6
feat(web): replace generic home icon with Grünerator brand icon
Movm Mar 31, 2026
8de3c9b
feat(voice): add TUS resumable uploads for audio transcription
Movm Mar 31, 2026
453772f
refactor(web): use HiOutlineDocumentText for docs navigation icon
Movm Mar 31, 2026
90cbf1d
fix(web): position Grünerator icon underscore bar to bottom-right of …
Movm Mar 31, 2026
c0386cc
fix(api): resolve __dirname ESM error in voice TUS transcription and …
Movm Mar 31, 2026
b4ced25
fix(web): restore MCP connect section on apps page, keep desktop as c…
Movm Mar 31, 2026
203da96
fix(web): disable agent mode for presse/social, add debug logging
Movm Mar 31, 2026
57dfb1d
fix(web): align docs page search input with title and button in same row
Movm Mar 31, 2026
90efa44
feat(web): use document preview cards in workplace recently created s…
Movm Mar 31, 2026
a89a3a0
refactor(web): remove workplace beta gate, split tools into main and …
Movm Mar 31, 2026
c264471
refactor(web): remove workplace beta gates from DesktopHome and Recen…
Movm Mar 31, 2026
5b546b2
fix(web): display tools and experimental tools sections side by side …
Movm Mar 31, 2026
45e76f4
fix(chat): remove duplicate "Neuer Chat" button from thread list
Movm Mar 31, 2026
ea4b283
feat(web): add template carousel and document grouping to docs overview
Movm Mar 31, 2026
878d081
feat(web): add sidebarOnly layout mode, use for docs overview
Movm Mar 31, 2026
9e40b5f
refactor(web): simplify docs menu to import-only, show hamburger in s…
Movm Mar 31, 2026
0f45747
fix(web): consolidate dark mode into single source of truth
Movm Mar 31, 2026
4e91481
fix(web): add dark:from-background to PageContainer gradient
Movm Mar 31, 2026
f64b470
fix(web): move docs CSS import from layer(components) to layer(legacy)
Movm Mar 31, 2026
7e560e9
docs: add dark mode architecture notes to CLAUDE.md
Movm Mar 31, 2026
e298147
refactor(web): stack tools sections vertically for better alignment
Movm Mar 31, 2026
7cbb526
feat(api): increase search depth for notebook-scoped chat queries
Movm Mar 31, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
183 changes: 183 additions & 0 deletions .agents/skills/better-auth-best-practices/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
---
name: better-auth-best-practices
description: Configure Better Auth server and client, set up database adapters, manage sessions, add plugins, and handle environment variables. Use when users mention Better Auth, betterauth, auth.ts, or need to set up TypeScript authentication with email/password, OAuth, or plugin configuration.
---

# Better Auth Integration Guide

**Always consult [better-auth.com/docs](https://better-auth.com/docs) for code examples and latest API.**

---

## Setup Workflow

1. Install: `npm install better-auth`
2. Set env vars: `BETTER_AUTH_SECRET` and `BETTER_AUTH_URL`
3. Create `auth.ts` with database + config
4. Create route handler for your framework
5. Run `npx @better-auth/cli@latest migrate`
6. Verify: call `GET /api/auth/ok` — should return `{ status: "ok" }`

---

## Quick Reference

### Environment Variables

- `BETTER_AUTH_SECRET` - Encryption secret (min 32 chars). Generate: `openssl rand -base64 32`
- `BETTER_AUTH_URL` - Base URL (e.g., `https://example.com`)

Only define `baseURL`/`secret` in config if env vars are NOT set.

### File Location

CLI looks for `auth.ts` in: `./`, `./lib`, `./utils`, or under `./src`. Use `--config` for custom path.

### CLI Commands

- `npx @better-auth/cli@latest migrate` - Apply schema (built-in adapter)
- `npx @better-auth/cli@latest generate` - Generate schema for Prisma/Drizzle
- `npx @better-auth/cli mcp --cursor` - Add MCP to AI tools

**Re-run after adding/changing plugins.**

---

## Core Config Options

| Option | Notes |
| ------------------ | ---------------------------------------------- |
| `appName` | Optional display name |
| `baseURL` | Only if `BETTER_AUTH_URL` not set |
| `basePath` | Default `/api/auth`. Set `/` for root. |
| `secret` | Only if `BETTER_AUTH_SECRET` not set |
| `database` | Required for most features. See adapters docs. |
| `secondaryStorage` | Redis/KV for sessions & rate limits |
| `emailAndPassword` | `{ enabled: true }` to activate |
| `socialProviders` | `{ google: { clientId, clientSecret }, ... }` |
| `plugins` | Array of plugins |
| `trustedOrigins` | CSRF whitelist |

---

## Database

**Direct connections:** Pass `pg.Pool`, `mysql2` pool, `better-sqlite3`, or `bun:sqlite` instance.

**ORM adapters:** Import from `better-auth/adapters/drizzle`, `better-auth/adapters/prisma`, `better-auth/adapters/mongodb`.

**Critical:** Better Auth uses adapter model names, NOT underlying table names. If Prisma model is `User` mapping to table `users`, use `modelName: "user"` (Prisma reference), not `"users"`.

---

## Session Management

**Storage priority:**

1. If `secondaryStorage` defined → sessions go there (not DB)
2. Set `session.storeSessionInDatabase: true` to also persist to DB
3. No database + `cookieCache` → fully stateless mode

**Cookie cache strategies:**

- `compact` (default) - Base64url + HMAC. Smallest.
- `jwt` - Standard JWT. Readable but signed.
- `jwe` - Encrypted. Maximum security.

**Key options:** `session.expiresIn` (default 7 days), `session.updateAge` (refresh interval), `session.cookieCache.maxAge`, `session.cookieCache.version` (change to invalidate all sessions).

---

## User & Account Config

**User:** `user.modelName`, `user.fields` (column mapping), `user.additionalFields`, `user.changeEmail.enabled` (disabled by default), `user.deleteUser.enabled` (disabled by default).

**Account:** `account.modelName`, `account.accountLinking.enabled`, `account.storeAccountCookie` (for stateless OAuth).

**Required for registration:** `email` and `name` fields.

---

## Email Flows

- `emailVerification.sendVerificationEmail` - Must be defined for verification to work
- `emailVerification.sendOnSignUp` / `sendOnSignIn` - Auto-send triggers
- `emailAndPassword.sendResetPassword` - Password reset email handler

---

## Security

**In `advanced`:**

- `useSecureCookies` - Force HTTPS cookies
- `disableCSRFCheck` - ⚠️ Security risk
- `disableOriginCheck` - ⚠️ Security risk
- `crossSubDomainCookies.enabled` - Share cookies across subdomains
- `ipAddress.ipAddressHeaders` - Custom IP headers for proxies
- `database.generateId` - Custom ID generation or `"serial"`/`"uuid"`/`false`

**Rate limiting:** `rateLimit.enabled`, `rateLimit.window`, `rateLimit.max`, `rateLimit.storage` ("memory" | "database" | "secondary-storage").

---

## Hooks

**Endpoint hooks:** `hooks.before` / `hooks.after` - Array of `{ matcher, handler }`. Use `createAuthMiddleware`. Access `ctx.path`, `ctx.context.returned` (after), `ctx.context.session`.

**Database hooks:** `databaseHooks.user.create.before/after`, same for `session`, `account`. Useful for adding default values or post-creation actions.

**Hook context (`ctx.context`):** `session`, `secret`, `authCookies`, `password.hash()`/`verify()`, `adapter`, `internalAdapter`, `generateId()`, `tables`, `baseURL`.

---

## Plugins

**Import from dedicated paths for tree-shaking:**

```
import { twoFactor } from "better-auth/plugins/two-factor"
```

NOT `from "better-auth/plugins"`.

**Popular plugins:** `twoFactor`, `organization`, `passkey`, `magicLink`, `emailOtp`, `username`, `phoneNumber`, `admin`, `apiKey`, `bearer`, `jwt`, `multiSession`, `sso`, `oauthProvider`, `oidcProvider`, `openAPI`, `genericOAuth`.

Client plugins go in `createAuthClient({ plugins: [...] })`.

---

## Client

Import from: `better-auth/client` (vanilla), `better-auth/react`, `better-auth/vue`, `better-auth/svelte`, `better-auth/solid`.

Key methods: `signUp.email()`, `signIn.email()`, `signIn.social()`, `signOut()`, `useSession()`, `getSession()`, `revokeSession()`, `revokeSessions()`.

---

## Type Safety

Infer types: `typeof auth.$Infer.Session`, `typeof auth.$Infer.Session.user`.

For separate client/server projects: `createAuthClient<typeof auth>()`.

---

## Common Gotchas

1. **Model vs table name** - Config uses ORM model name, not DB table name
2. **Plugin schema** - Re-run CLI after adding plugins
3. **Secondary storage** - Sessions go there by default, not DB
4. **Cookie cache** - Custom session fields NOT cached, always re-fetched
5. **Stateless mode** - No DB = session in cookie only, logout on cache expiry
6. **Change email flow** - Sends to current email first, then new email

---

## Resources

- [Docs](https://better-auth.com/docs)
- [Options Reference](https://better-auth.com/docs/reference/options)
- [LLMs.txt](https://better-auth.com/llms.txt)
- [GitHub](https://github.com/better-auth/better-auth)
- [Init Options Source](https://github.com/better-auth/better-auth/blob/main/packages/core/src/types/init-options.ts)
Loading
Loading