Back to skills
SKILL.md
Auth Patterns 1
ASecurityBetter-auth integration for authentication. Use when implementing login, registration, protected routes, or email verification.
- 2 stars
- 0 votes
- 0 copies
- 0 views
- Added September 27, 2026
Works with
Security analysis
100/100Pro scans all 5 files and shows the line behind each finding
npx -y skills add David-Li0406/meta-skill-evloving --skill auth-patterns-1 --agent claude-codeAre you the author of Auth Patterns 1?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/david-li0406-auth-patterns-1)---
name: auth-patterns
# prettier-ignore
description: Better-auth integration for authentication. Use when implementing login, registration, protected routes, or email verification.
---
# Auth Patterns
## Quick Pattern
```typescript
// Login form
export const login = form(schema, async ({ email, password }) => {
const event = getRequestEvent();
await auth.api.signInEmail({
body: { email, password },
headers: event.request.headers,
});
redirect(303, '/dashboard'); // Outside try/catch
});
// Protected query
export const get_data = guarded_query(() => {
return { message: 'Protected data' };
});
```
## Core Principles
- Use `getRequestEvent()` for headers (cookie access)
- Redirect MUST be outside try/catch (throws error)
- Use `guarded_query/form/command` for protected endpoints
- Email verification required before login
- Commands cannot redirect - use client-side `goto()`
## Reference Files
- [auth-setup.md](references/auth-setup.md) - Complete better-auth
configuration
- [auth-usage.md](references/auth-usage.md) - All auth patterns and
examples
- [email-verification.md](references/email-verification.md) - Email
verification flow
Files in this skill
- README.md
- SKILL.md
- references/auth-setup.md
- references/auth-usage.md
- references/email-verification.md
Attribution
Comments
Loading comments…