邮箱 OTP 无密码登录,验证后签发自定义 JWT,不存储密码
auth_template — Next.js SaaS模板
作者 AmarMuric04
基于 Next.js App Router 的认证启动模板,提供邮箱 OTP 无密码登录、NextAuth 的 Google/GitHub OAuth、Prisma + Supabase 数据层,并内置一个可扩展的 AI 聊天机器人界面。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
通过 NextAuth 接入 Google 与 GitHub 的 OAuth 登录
Supabase PostgreSQL + Prisma ORM,schema 已含用户、OTP、会话与聊天数据
内置可扩展的 AI 聊天机器人 UI,聊天记录存入 Supabase
基于 Next.js App Router 的模块化目录结构,响应式界面
模板详细介绍
这个模板面向需要快速搭建认证系统的 SaaS 或应用项目。它把两条认证路径放在同一个 Next.js 项目里:一条是自研的邮箱 OTP 无密码登录,验证通过后签发自定义 JWT,走无状态会话;另一条是通过 NextAuth 接入 Google 和 GitHub 的 OAuth 登录。数据层使用 Supabase 提供的 PostgreSQL,并通过 Prisma ORM 访问,仓库中已包含用户、OTP 验证、会话和聊天机器人数据的 schema。
界面部分为响应式设计,包含登录页和内置的 AI 聊天机器人 UI,聊天记录写入 Supabase。项目结构按 App Router 组织,认证相关 API 放在 pages/api/auth 下,认证与 JWT 工具集中在 lib 目录。
使用前需要自行准备 Supabase 数据库、JWT 密钥、NextAuth 密钥以及 Google/GitHub 的 OAuth 凭据,并执行 Prisma 的 generate 与 db push 初始化表结构。README 中提到的单元测试与端到端测试标注为“即将推出”,仓库当前未包含测试套件。模板采用 MIT 许可,可免费使用、修改和分发,但演示素材、字体、图标等第三方资源以及 Supabase、托管、AI 等外部服务需另行核对许可与费用。
适合你的项目吗?
适用场景
- 为 SaaS 产品搭建同时支持 OTP 与 OAuth 的登录入口
- 在已有 Next.js 项目中引入 Prisma + Supabase 的认证数据模型
- 需要内置客服或引导型 AI 聊天界面的应用原型
- 作为学习 NextAuth 与自定义 JWT 两种会话方案并存的参考项目
适合人群
- 使用 Next.js App Router 并计划接入 Supabase 的开发者
- 需要快速获得可运行认证流程的 SaaS 或应用项目
- 希望同时保留无密码登录与第三方 OAuth 两种方式的产品
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
克隆仓库后执行 npm install 或 yarn 安装依赖
- 2
复制 .env.example 为 .env.local,填写 DATABASE_URL、JWT_SECRET、Supabase 与 NextAuth 相关变量以及 Google/GitHub 的 OAuth 凭据
- 3
执行 npx prisma generate 与 npx prisma db push 初始化数据库表结构
- 4
可选执行 npm run seed 写入种子数据,然后运行 npm run dev 启动本地开发服务
- 5
README 中的测试部分标注为即将推出,仓库当前未提供 Jest 或 Playwright 测试
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 使用前必须自行准备并连接一个 PostgreSQL 数据库(README 推荐 Supabase),需提供 DATABASE_URL 等连接信息,属于外部服务依赖。
- 需要自行创建 Supabase 项目并提供 SUPABASE_URL 与 SUPABASE_SERVICE_ROLE_KEY,聊天记录与数据均依赖该外部服务。
- OAuth 登录需自行在 GitHub 注册应用并配置 GITHUB_ID/GITHUB_SECRET 凭据,否则该登录方式不可用。
- Google OAuth 登录需自行申请 Google 客户端凭据并配置 GOOGLE_CLIENT_ID/GOOGLE_CLIENT_SECRET。
- NextAuth 会话需自行生成并配置 NEXTAUTH_SECRET 与 NEXTAUTH_URL,属于部署前必须完成的配置。
- 自定义 JWT 签发依赖自行设置的 JWT_SECRET,缺失则 OTP 登录流程无法正常工作。
- OTP 登录需要可用的邮件发送服务;README 仅说明开发环境可模拟,生产环境需自行接入邮件服务并承担相应费用。
- 部署示例指向 Vercel,实际托管需自行注册账号并可能产生费用,属于外部服务成本。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
DATABASE_URL=postgresql://user:password@host:port/dbname
README 原文
SUPABASE_URL=https://your-project.supabase.co
README 原文
GITHUB_ID=your_github_id
README 原文
GOOGLE_CLIENT_ID=your_google_client_id
README 原文
NEXTAUTH_SECRET=nextauth_secret_here
README 原文
JWT_SECRET=your_jwt_secret
README 原文
An OTP code is emailed (or mocked in dev)
README 原文
https://github.com/AmarMuric04/auth_template/blob/master/LICENSEhttps://github.com/AmarMuric04/auth_template/blob/master/README.mdOne-click deploy to **Vercel**
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-03。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 82 / 100
- 技术栈
- Next.js · React
- 网站类型
- SaaS · 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2025-05-10
- 截图检查日期
- 2026-10-03
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: 6f72008bb2512b9212242a543bb45041b55247c76a0099e8c77a619c4ff1c305
2026-10-03T07:23:49.145Z
来源文件 / 仓库# 🔐 Full Auth Template – Custom JWT + OTP + OAuth (Next.js + Prisma + Supabase) A modern and secure **authentication template** built with **Next.js**, featuring: - 🔑 **Custom credentials auth** using **passwordless OTP** (no passwords stored!) - 🔐 **OAuth support** with **GitHub** and **Google** (via NextAuth) - ⚙️ **Custom JWT-based system** for credentials auth - 🧠 A custom-built **AI chatbot** integrated and ready to go - 🎨 Fully responsive, modern UI - 🧩 **Supabase** PostgreSQL database with **Prisma ORM** Designed for scalability and security, this starter gives you everything you need to bootstrap a real-world auth system. --- ## 🚀 Features - ✅ Passwordless authentication via OTP codes (email-based) - 🔐 OAuth support with GitHub and Google via NextAuth - 🔑 Custom credentials login with stateless JWT handling - 🧠 Integrated AI chatbot (drop-in use or extendable) - 📱 Fully responsive and mobile-friendly - 💽 PostgreSQL + Supabase backend with Prisma ORM - 🧰 Built with **Next.js App Router** and modular component design --- ## 🧱 Tech Stack | Layer | Tech | |--------------|-----------------| | Frontend | Next.js | | Backend | Next.js (API) | | Auth (OAuth) | NextAuth | | Auth (OTP) | Custom JWT + OTP | | DB | PostgreSQL via Supabase | | ORM | Prisma | | AI Chatbot | Custom-built (plug-and-play) | --- ## 🔧 Getting Started ### 1. Clone the Repository ```bash git clone https://github.com/amarmuric04/auth-template.git cd auth-template ``` ### 2. Install Dependencies ```bash npm install # or yarn ``` ### 3. Configure Environment Variables Copy `.env.example` to `.env.local`: ```env DATABASE_URL=postgresql://user:password@host:port/dbname # JWT Secrets JWT_SECRET=your_jwt_secret # Supabase SUPABASE_URL=https://your-project.supabase.co SUPABASE_SERVICE_ROLE_KEY=your_service_role # NextAuth (for OAuth) NEXTAUTH_SECRET=nextauth_secret_here NEXTAUTH_URL=http://localhost:3000 GITHUB_ID=your_github_id GITHUB_SECRET=your_github_secret GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret ``` ### 4. Set Up the Database ```bash npx prisma generate npx prisma db push ``` > ✅ Schema already included for user, OTP verification, sessions, and chatbot data. ### 5. Seed the Database (Optional) Use mock data or your own: ```bash npm run seed ``` ### 6. Start the App ```bash npm run dev # or yarn dev ``` Open [http://localhost:3000](http://localhost:3000) --- ## 🧬 How Authentication Works ### 🔑 OTP-based Credentials (Passwordless) - Users login with email - An OTP code is emailed (or mocked in dev) - OTP is verified and a **JWT** is issued - Stateless auth: sessions are stored client-side via JWT ### 🧷 OAuth Login - Handles GitHub and Google using **NextAuth** - Session strategy can be configured (JWT or DB-based) --- ## 🤖 AI Chatbot A smart, extendable chatbot built directly into the UI. - Custom hook/API integration - Chat log stored in Supabase - UI is mobile-ready and responsive - Great for onboarding or user help center --- ## 📁 Project Structure `` /app → Next.js App Router pages /components → UI and shared components /lib → Utilities (auth, jwt, helpers) /prisma → Prisma schema and client /pages/api/auth → Custom API for OTP + NextAuth /styles → Global CSS / Tailwind /chatbot → AI bot logic and UI `` --- ## 🔐 Security Notes - Passwordless auth = more secure and lower friction - OTP expires after X minutes (configurable) - JWT is signed with server-only secret - OAuth tokens never touch your DB directly - Fully stateless login path with fallback to OAuth --- ## 🧪 Testing Coming soon: - Jest for unit tests - Playwright for E2E - Auth flow test harness --- ## 📦 Deployment - One-click deploy to **Vercel** - Add env variables in Vercel dashboard - Works with Docker (optional) --- ## 📜 License MIT --- Built for modern apps that need secure, scalable, and flexible authentication + AI support.
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

ai-website-cloner-template
Clone any website with one command using AI coding agents
Next.js · 启动器

Next.js SaaS Starter
Next.js SaaS Starter 是 Next.js 官方维护的 SaaS 起点模板,定位介于学习资源和可直接部署的脚手架之间。
Next.js · SaaS

Next.js Commerce
Next.js Commerce 是 Vercel 团队维护的电商启动模板,基于 Next.js App Router 构建,采用服务端渲染、React Server Components、Server Actions …
Next.js · 电商

Next-js-Boilerplate
Next-js-Boilerplate 是一个面向 Next.js 16、Tailwind CSS 4 和 TypeScript 的启动器,核心定位是开发者体验优先。
Next.js · 启动器

tailwind-nextjs-starter-blog
tailwind-nextjs-starter-blog 是一个面向个人技术博客的 Next.js 与 Tailwind CSS 启动模板,其 v2 版本基于 App Router 与 React Server Comp…
Next.js · 博客

next-forge
Production-grade Turborepo template for Next.js apps.
Next.js · 启动器
