mcpField
A
authentication

authentication

github.com/andrelandgraf安全23132 次安装21 周前更新
代码仓库

关于 authentication

面向 Next.js 应用开发者的认证配方,按步骤使用 Better Auth 构建邮箱验证、密码重置、受保护路由和账户管理流程。

主要功能

  1. 01邮箱密码认证
  2. 02邮箱验证与密码重置
  3. 03认证页面与组件
  4. 04账户资料和会话管理
  5. 05服务端路由保护

适用场景

  1. 01为应用添加注册和登录流程
  2. 02实现邮箱验证及密码重置邮件
  3. 03管理账户资料、密码和会话
  4. 04限制特定页面仅供已认证用户访问

安装

复制下面的命令,在终端中运行。

$npx skills add https://github.com/andrelandgraf/fullstackrecipes --skill authentication

安装后在 Claude Code 中输入/authentication确认已加载。

详细介绍

身份验证

完整的身份验证系统,包含 Better Auth、电子邮件验证、密码重置、受保护路由和账户管理。

前置条件

请先按顺序完成以下教程:

使用 better-env 进行类型安全的环境配置

使用 better-env 配置模块,实现类型安全的服务端/公共环境变量访问、功能标志和二选一凭据约束。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/config-schema-setup
Neon + Drizzle 设置

使用 Drizzle ORM 将 Next.js 应用连接到 Neon Postgres,并针对 Vercel 无服务器函数优化连接池。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/neon-drizzle-setup
在 Vercel 上运行 Next.js

创建一个基于 Bun 运行的 Next.js 应用,配置开发环境,并部署到 Vercel,实现推送时自动部署。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/nextjs-on-vercel
Shadcn UI 与主题设置

添加支持深色模式的 Shadcn UI 组件,并使用 next-themes。包括主题提供程序和 CSS 变量配置。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/shadcn-ui-setup

教程集 — 按顺序完成以下教程

Resend 设置

配置 Resend,用于发送密码重置和电子邮件验证等事务性邮件。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/resend-setup
Better Auth 设置

使用 Better Auth、Drizzle ORM 和 Neon Postgres 添加用户身份验证。完成基于电子邮件/密码身份验证的基础设置。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-setup
Better Auth 电子邮件

使用 Resend 为 Better Auth 添加电子邮件验证、密码重置和账户管理邮件。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-emails
Better Auth 组件

为身份验证流程添加 UI 组件和页面,包括登录、注册、忘记密码、重置密码和电子邮件验证。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-components
Better Auth 个人资料与账户

添加完整的账户设置页面,支持编辑个人资料、更改密码、更新电子邮件、管理会话和删除账户。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-profile
Better Auth 受保护路由

添加服务端路由保护,在特定页面强制要求身份验证,同时让其他页面保持公开。

curl -H "Accept: text/markdown" https://fullstackrecipes.com/api/recipes/better-auth-protected-routes
身份验证最佳实践

使用 Better Auth 实现客户端和服务端身份验证。涵盖会话访问、受保护路由、登录/退出和获取用户数据。

bunx skills add andrelandgraf/fullstackrecipes/skills -s authentication-best-practices

评论

支持 Markdown