Authentication
Core authentication utilities and hooks
The authentication registry provides a complete server-side auth flow with password sign-in, OAuth providers, persistent sessions, access/refresh tokens, and a React Query session provider.
The registry item auth installs the server core, built-in OAuth providers, auth configuration, and the client useSession hook. Database integrations are separate registry blocks for Drizzle, Prisma, and Mongoose.
What is included
The auth block contains:
createAuthand the requesthandlers.- Session and current-user helpers.
- Password sign-in and sign-out.
- Access-token verification and refresh.
- OAuth provider implementations.
- Cookie serialization and token lifecycle handling.
SessionProvideranduseSession.
Registry items
| Registry item | Purpose |
|---|---|
auth | Core authentication runtime and React session provider. |
auth-adapter-drizzle | Drizzle ORM schema and adapter. |
auth-adapter-prisma | Prisma schema and adapter. |
auth-adapter-mongoose | Mongoose schema and adapter. |
Providers
The built-in OAuth providers are:
Google, Github, Discord, Facebook, Figma, and Vercel.
Each provider follows the same BaseProvider interface and maps the provider's user profile into the registry's OAuthAccount shape.
Security model
The server stores only a hash of the refresh-token secret. Refresh tokens are split into an ID and secret, while access tokens are signed JWTs. OAuth state and PKCE values are stored in short-lived cookies during the authorization flow.
Installation
The authentication system consists of the core auth package and an optional database adapter. Install auth first, then choose the adapter that matches your application's database layer.
npx shadcn add https://ui.tiesen.id.vn/r/auth.jsonDatabase adapters
Database adapters connect the authentication layer to your persistence layer. Choose one adapter based on the database technology already used in your application.
Drizzle
Use the Drizzle adapter when your application uses Drizzle ORM. It provides the authentication schema and persistence operations for relational databases supported by your Drizzle setup.
npx shadcn add https://ui.tiesen.id.vn/r/auth-adapter-drizzle.jsonPrisma
Use the Prisma adapter when your application uses Prisma ORM. The adapter integrates with your generated Prisma client and provides the models required by the authentication system.
npx shadcn add https://ui.tiesen.id.vn/r/auth-adapter-prisma.jsonMongoose
Use the Mongoose adapter when your application uses MongoDB with Mongoose. It provides the authentication models and persistence layer for users, accounts, and sessions.
npx shadcn add https://ui.tiesen.id.vn/r/auth-adapter-mongoose.jsonYou only need one database adapter. The authentication API remains the same regardless of which adapter you choose.