betterauth

Installation
SKILL.md

Better Auth Integration Skill

This skill provides the source of truth for integrating Better Auth into a polyglot stack (Go backend + React frontend). It ensures secure session management, type-safe API calls, and seamless TanStack Query integration.

Architectural Standards

1. Unified Auth Schema & Plugins

  • Database: Use the Better Auth standard schema. Standardize table names to user, session, account, verification.
  • Plugins: Enable and configure:
    • organization: For multi-tenant isolation.
    • sso: For SAML/OIDC enterprise login.
    • two-factor: For TOTP/Email/SMS MFA.
    • admin: For user impersonation and management.

2. Go Backend Integration (The Bridge)

  • Middleware: Implement a robust middleware that:
    1. Extracts the better-auth.session_token cookie.
    2. Validates it against the session table.
    3. Handles Token Refresh by checking the expiresAt and performing a silent refresh via the Better Auth API if needed.
  • Context: Store the full User and Organization objects in the request context for downstream RBAC.
Related skills
Installs
1
First Seen
8 days ago