Menu

User Authentication and Database

Prerequisites

Before starting to develop new features, please ensure you have completed the following prerequisites:

Architecture Overview

lib/auth/
├── auth-client.ts      # Better-auth client definition
├── index.ts            # Better-auth core configuration
└── server.ts           # Server-side common methods, including: get session, check if current user is admin
 
lib/db/
├── migrations/         # Migration files generated by `npm run db:generate` command
├── config.ts           # Database parameter configuration, automated processing
├── index.ts            # Drizzle ORM configuration entry point
└── schema.ts           # Database table definitions
 
components/auth/
├── AuthGuard.tsx       # Route guard, protects routes that require login access and admin-only routes
├── GoogleOneTap.tsx    # Google One Tap login script
├── LoginDialog.tsx     # Login modal dialog
└── LoginForm.tsx       # Login form
 
actions/
├── users/              # User-related database operations
├── team/               # Data layer of the team management page
├── blogs/              # Blog-related database operations
└── .../                # Others

Teams

Since v4.0.0 the boilerplate ships team support built on the Better Auth organization plugin: the organization as a billing subject, a shared credit pool, seat management and email invitations. See Teams and Organizations.

The following documentation will expand on the current architecture.