npx skills add ...
npx skills add giuseppe-trisciuoglio/developer-kit --skill better-auth
Provides Better Auth integration patterns for NestJS backend and Next.js frontend with Drizzle ORM and PostgreSQL. Use when setting up Better Auth with NestJS backend, integrating Next.js App Router frontend, configuring Drizzle ORM schema, implementing social login (GitHub, Google), adding plugins (2FA, Organization, SSO, Magic Link, Passkey), implementing email/password authentication with session management, or creating protected routes and middleware.
npx skills add giuseppe-trisciuoglio/developer-kit --skill better-auth
Better Auth is a type-safe authentication framework for TypeScript supporting multiple providers, 2FA, SSO, organizations, and passkeys. This skill covers integration patterns for NestJS backend with Drizzle ORM + PostgreSQL and Next.js App Router frontend.
See references/nestjs-setup.md for complete backend setup, references/plugins.md for plugin configuration.
Install dependencies
Create Drizzle config (drizzle.config.ts)
Generate and run migrations
Checkpoint: Verify tables created: psql $DATABASE_URL -c "\dt" should show user, account, session, verification_token tables.
Create database module - Set up Drizzle connection service
Configure Better Auth instance
Create auth controller
Checkpoint: Test endpoint GET /auth/get-session returns { session: null } when unauthenticated (no error).
Configure auth client (lib/auth.ts)
Add middleware (middleware.ts)
Create sign-in page with form or social buttons
Checkpoint: Navigating to /dashboard when logged out should redirect to /sign-in.
Add plugins from references/plugins.md:
2FA: twoFactor({ issuer: 'AppName', otpOptions: { sendOTP } })
Passkey: passkey({ rpID: 'domain.com', rpName: 'App' })
Organizations: organization({ avatar: { enabled: true } })
Magic Link: magicLink({ sendMagicLink })
SSO: sso({ saml: { enabled: true } })
Checkpoint: After adding plugins, re-run migrations and verify new tables exist.
Input: Display user data in a Next.js Server Component.
Output: Renders user info for authenticated users; redirects unauthenticated to sign-in.
Input: User has 2FA enabled and wants to sign in, marking device as trusted.
Output: User authenticated; device trusted for 30 days without 2FA prompt.
Input: Enable passkey (WebAuthn) authentication for passwordless login.
Output: Users can register and authenticate with biometrics, PIN, or security keys.
For more examples (backup codes, organizations, magic link, conditional UI), see references/plugins.md and references/passkey.md.
.env, add to .gitignoreopenssl rand -base64 32 for BETTER_AUTH_SECRETngrok for local testing)email, userId for performancenpx better-auth typegen for full TypeScript coverage.env to .gitignore; never commit OAuth secrets or DB credentialsreferences/nestjs-setup.md - Complete NestJS backend setupreferences/nextjs-setup.md - Complete Next.js frontend setupreferences/plugins.md - Plugin configuration (2FA, passkey, organizations, SSO, magic link)references/mfa-2fa.md - Detailed MFA/2FA guidereferences/passkey.md - Detailed passkey implementationreferences/schema.md - Drizzle schema referencereferences/social-providers.md - Social provider configuration