# Configure Better Auth Securely

Authentication setup often fails through mismatched adapters, session storage, plugins, or environment settings. This skill provides focused Better Auth configuration and security guidance.

## Install

```bash
npx skillstore add better-auth/better-auth-best-practices
```

## Metadata

- Status: approved
- Slug: better-auth-better-auth-best-practices
- Skillstore revision: r1
- Version status: missing
- Tree hash: 952c98be1354970d565e52738d26d78c6725afe94ccb4593beb5eb70e12f6cb1
- Author: better-auth
- GitHub username: better-auth
- License: MIT
- Repository: https://github.com/better-auth/skills/tree/main/better-auth/best-practices/
- Ref: d71c7417a35d5c2624161bd2fe8de8a41a362128
- Supported tools: Claude, Codex, Claude Code
- Audit status: complete
- Agent install advisory: allowed
- Manual install advisory: allowed
- Artifact signature: available
- Audit attestation: unavailable
- Human verification: not\_verified
- Risk factors: external\_commands, network
- Quality score: 77
- Quality tier: bronze
- Public page: https://skillstore.pages.dev/skills/better-auth-better-auth-best-practices
- Manifest: https://skillstore.pages.dev/api/skills/better-auth-better-auth-best-practices/manifest

## Capabilities

- Outlines Better Auth server and client setup workflows.
- Explains direct database connections and Prisma, Drizzle, and MongoDB adapters.
- Describes session storage priority, cookie cache strategies, and invalidation options.
- Lists email, OAuth, plugin, hook, and rate limiting configuration points.
- Highlights secure cookies, trusted origins, CSRF checks, and origin checks.
- Identifies common model naming, schema generation, and Drizzle configuration errors.

## Use Cases

- Start TypeScript Authentication: Plan a Better Auth server, client, route handler, environment variables, and initial database schema.
- Review Session Security: Assess storage priority, cookie strategy, secure cookies, trusted origins, and rate limiting before deployment.
- Integrate Database Adapters: Choose and configure a direct driver, Prisma, Drizzle, or MongoDB adapter while avoiding model naming errors.

## Prompt Templates

### Plan Basic Setup

```
Plan a basic Better Auth setup for my TypeScript application with email and password authentication.
```

### Configure Drizzle

```
Configure Better Auth with Drizzle and PostgreSQL, including environment variables, adapter setup, schema generation, and a development migration workflow.
```

### Audit Session Settings

```
Review my Better Auth session configuration for storage priority, cookie caching, secure cookies, trusted origins, and rate limiting.
```

### Design Advanced Architecture

```
Design a production Better Auth architecture with secondary storage, OAuth, two-factor authentication, hooks, and typed clients. Identify migration and security risks.
```

## Limitations

- It is a reference guide and does not inspect an application automatically.
- It does not replace current Better Auth documentation or release notes.
- It does not validate database credentials, provider settings, or deployment infrastructure.
- Its migration commands can change files or database state and require user approval.

## Best Practices

- Confirm package installation and migration commands before execution.
- Keep secrets in environment variables and use secure cookies in production.
- Recheck current documentation and regenerate schemas after plugin changes.

## Anti Patterns

- Do not disable CSRF or origin checks without a documented security review.
- Do not use database table names where an adapter expects model names.
- Do not apply generated migrations to production without reviewing targets, changes, and backups.

## Security Audit

- Audited at: 2026-07-12T14:35:28.779\+00:00
- Summary: Seven command findings are confirmed because the setup guide recommends package execution, schema generation, migrations, or tool configuration changes. The other 63 detections are Markdown formatting, safe examples, or official reference links with no automatic execution or exfiltration.

## Stats

- Views: 203
- Downloads: 23
- Favorites: 0
- Popularity score: 0
