auth-patterns

// 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 });

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "auth-patterns" with this command: npx skills add spences10/devhub-crm/spences10-devhub-crm-auth-patterns

Auth Patterns

Quick Pattern

// 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 - Complete better-auth configuration

  • auth-usage.md - All auth patterns and examples

  • email-verification.md - Email verification flow

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

Coding

component-testing-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

auth-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

techdebt-finder

No summary provided by upstream source.

Repository SourceNeeds Review
Coding

terminal-optimization

No summary provided by upstream source.

Repository SourceNeeds Review