authentication
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAuthentication
认证系统
Complete authentication system with Better Auth, email verification, password reset, protected routes, and account management.
基于Better Auth的完整认证系统,包含邮箱验证、密码重置、受保护路由以及账户管理功能。
Prerequisites
前置条件
Complete these recipes first (in order):
请按顺序完成以下准备步骤:
Type-Safe Environment Configuration
类型安全的环境配置
Type-safe environment variable validation using Zod with a Drizzle-like schema API. Supports server/public fields, feature flags, either-or constraints, and client-side protection.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/config-schema-setup使用Zod结合类Drizzle的Schema API实现类型安全的环境变量验证。支持服务端/公共字段、功能标志、二选一约束以及客户端保护。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/config-schema-setupNeon + Drizzle Setup
Neon + Drizzle 环境搭建
Connect a Next.js app to Neon Postgres using Drizzle ORM with optimized connection pooling for Vercel serverless functions.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/neon-drizzle-setup使用Drizzle ORM将Next.js应用连接到Neon Postgres,并针对Vercel无服务器函数优化连接池。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/neon-drizzle-setupNext.js on Vercel
Vercel上的Next.js部署
Create a Next.js app running on Bun, configure the development environment, and deploy to Vercel with automatic deployments on push.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/nextjs-on-vercel创建基于Bun运行的Next.js应用,配置开发环境,并部署到Vercel,实现代码推送时自动部署。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/nextjs-on-vercelShadcn UI & Theming
Shadcn UI 与主题配置
Add Shadcn UI components with dark mode support using next-themes. Includes theme provider and CSS variables configuration.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/shadcn-ui-setup使用next-themes添加支持深色模式的Shadcn UI组件,包含主题提供器和CSS变量配置。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/shadcn-ui-setupCookbook - Complete These Recipes in Order
实操指南 - 按顺序完成以下步骤
Resend Setup
Resend 环境配置
Configure Resend for transactional emails like password resets and email verification.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/resend-setup配置Resend以处理密码重置、邮箱验证等事务性邮件。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/resend-setupBetter Auth Setup
Better Auth 基础配置
Add user authentication using Better Auth with Drizzle ORM and Neon Postgres. Base setup with email/password authentication.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-setup结合Drizzle ORM和Neon Postgres,使用Better Auth添加用户认证功能。完成邮箱/密码认证的基础配置。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-setupBetter Auth Emails
Better Auth 邮件功能
Add email verification, password reset, and account management emails to Better Auth using Resend.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-emails使用Resend为Better Auth添加邮箱验证、密码重置以及账户管理相关的邮件功能。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-emailsBetter Auth Components
Better Auth 组件集成
Add UI components and pages for authentication flows including sign in, sign up, forgot password, reset password, and email verification.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-components添加认证流程所需的UI组件和页面,包括登录、注册、忘记密码、重置密码以及邮箱验证。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-componentsBetter Auth Profile & Account
Better Auth 个人资料与账户管理
Add a complete account settings page with profile editing, password changes, email updates, session management, and account deletion.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-profile添加完整的账户设置页面,支持资料编辑、密码修改、邮箱更新、会话管理以及账户删除功能。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-profileBetter Auth Protected Routes
Better Auth 受保护路由配置
Add server-side route protection to enforce authentication on specific pages while keeping others public.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-protected-routes添加服务端路由保护,对特定页面强制要求认证,其余页面保持公开访问。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-protected-routesWorking with Authentication
认证功能的实际使用
Use Better Auth for client and server-side authentication. Covers session access, protected routes, sign in/out, and fetching user data.
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/using-authentication使用Better Auth实现客户端和服务端认证,涵盖会话访问、受保护路由、登录/登出以及用户数据获取。
bash
curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/using-authentication