Next.js App Router 同时承载前端页面与 API 路由
e-commerce-template — Next.js 电商模板
作者 AmarMuric04
基于 Next.js 的全栈电商起步模板,集成 NextAuth 认证、Drizzle ORM 与 Neon PostgreSQL,提供商品列表、详情、购物车和结账骨架。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 3
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
NextAuth 认证支持 Google、GitHub OAuth 与邮箱密码登录
Drizzle ORM 定义 schema,可推送到 Neon 或其他 PostgreSQL 实例
内置商品列表、商品详情、购物车与结账骨架
提供 mock 数据种子脚本,便于先用示例数据启动
包含商品卡片、购物车弹窗、认证表单等可复用组件
模板详细介绍
该模板是一个用 Next.js 同时实现前后端的电商应用起步项目。认证层使用 NextAuth,支持 OAuth(Google、GitHub)与邮箱密码两种方式;数据层使用 Drizzle ORM 连接 PostgreSQL,README 以 Neon 作为托管数据库示例,并说明只要 DATABASE_URL 指向兼容 PostgreSQL 的实例即可替换。
功能上覆盖商品列表、商品详情、购物车以及结账骨架,结账部分需要自行接入支付服务商。项目提供可复用的商品卡片、购物车弹窗和认证表单组件,并附带 mock 数据种子脚本,便于在没有真实商品数据时先跑通流程。数据库 schema 位于 drizzle/schema 目录,通过 drizzle-kit push 推送到数据库。
限制方面:README 将测试标注为“即将推出”,未包含 Playwright 或 React Testing Library 的集成;结账流程不含支付实现;样式是否使用 TailwindCSS 取决于具体配置。模板的 MIT 许可仅覆盖代码本身,演示图片、字体、图标等第三方素材以及域名、托管、数据库、支付等外部服务需另行核对与承担费用。
适合你的项目吗?
适用场景
- 学习 Next.js 全栈架构与 NextAuth、Drizzle 的配合方式
- 作为自建商店的起点,替换商品数据与支付服务商后继续开发
- 在本地用 mock 数据快速验证商品浏览与购物车流程
- 以 PostgreSQL 兼容数据库为基础搭建电商后端结构
适合人群
- 希望基于 Next.js 搭建电商项目的开发者
- 需要现成认证与数据库 schema 起步的全栈学习者
- 计划接入自有 PostgreSQL 与支付服务的独立开发者
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
克隆仓库后执行 npm install 或 yarn 安装依赖
- 2
参照 .env.example 创建 .env.local,配置 DATABASE_URL、NEXTAUTH_SECRET、NEXTAUTH_URL,OAuth 需额外填写对应客户端 ID 与密钥
- 3
运行 npx drizzle-kit push 将 drizzle/schema 中的 schema 推送到数据库
- 4
可选执行 npm run seed 写入 mock 数据,或自行通过 SQL 或数据库面板插入商品
- 5
执行 npm run dev 后访问 http://localhost:3000
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
- 结账流程仅为骨架,不包含支付实现,需自行接入支付服务商。
- 测试集成尚未提供,Playwright 与 React Testing Library 的集成标注为即将推出。
- 样式是否使用 TailwindCSS 取决于具体配置,并非默认强制包含。
- README 以 Neon 作为 PostgreSQL 托管示例,使用该服务需自行注册并承担相应费用。
- OAuth 登录为可选项,启用 Google 或 GitHub 登录需自行申请并配置对应的客户端 ID 与密钥。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
Checkout skeleton (add your own payment provider)
README 原文
Coming soon: integration with Playwright and React Testing Library.
README 原文
Styling:** TailwindCSS (optional depending on setup)
README 原文
Database:** PostgreSQL (hosted on [Neon](https://neon.tech))
README 原文
https://github.com/AmarMuric04/e-commerce-template/blob/master/LICENSEhttps://github.com/AmarMuric04/e-commerce-template/blob/master/README.mdOAuth Providers (optional)
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-11。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 79 / 100
- 技术栈
- Next.js · React
- 网站类型
- 电商
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2025-05-10
- 截图检查日期
- 2026-10-11
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
审核声明: [email protected] · 2026-10-11
查看当时使用的来源资料
SHA-256: 9256bd1d6978132c27af8705f6ef1da486f6787d05dc5069ea5206568a0d34d1
2026-10-11T06:30:37.164Z
来源文件 / 仓库# 🛒 Full Stack E-Commerce App (Next.js + NextAuth + PostgreSQL + Drizzle) A full-featured e-commerce web application built with **Next.js** for both frontend and backend, powered by **NextAuth** for authentication (OAuth + Credentials), and backed by a **PostgreSQL** database using **Drizzle ORM** hosted on **Neon**. This project is **ready-to-use**, modular, and easy to configure. Whether you want to use **mock data** for testing or connect it with **real products**, it's just a few steps away. --- ## 🔧 Tech Stack - **Frontend:** Next.js (App Router) - **Backend:** Next.js (API Routes) - **Authentication:** NextAuth.js (OAuth + Credentials) - **ORM:** Drizzle ORM - **Database:** PostgreSQL (hosted on [Neon](https://neon.tech)) - **Styling:** TailwindCSS (optional depending on setup) - **Deployment Ready:** Vercel / Docker / Custom hosting --- ## 🚀 Getting Started ### 1. Clone the Repository ```bash git clone https://github.com/amarmuric04/e-commerce-template.git cd e-commerce-template ``` ### 2. Install Dependencies ```bash npm install # or yarn ``` ### 3. Set Up Environment Variables Create a `.env.local` file based on the provided `.env.example`: ``env DATABASE_URL=postgresql://user:password@host/dbname NEXTAUTH_SECRET=your_nextauth_secret NEXTAUTH_URL=http://localhost:3000 # OAuth Providers (optional) GITHUB_ID=your_github_client_id GITHUB_SECRET=your_github_client_secret GOOGLE_CLIENT_ID=your_google_client_id GOOGLE_CLIENT_SECRET=your_google_client_secret ``` ### 4. Push Schema to the Database If using Drizzle with Neon: ```bash npx drizzle-kit push ``` Alternatively, if you're using your own PostgreSQL setup, just make sure `DATABASE_URL` is set correctly and run the same command. ### 5. Use Mock or Real Data You can choose to populate your database with mock data: ```bash npm run seed ``` Or manually insert your own data via a GUI (like Neon dashboard) or SQL tool. ### 6. Start the App ```bash npm run dev # or yarn dev ``` Visit **http://localhost:3000** to see it in action. --- ## 🧩 Features - 🔐 **Authentication** - OAuth (Google, GitHub) - Email + Password (Credentials) - 🗂️ **Reusable Components** - Product cards, cart modal, auth forms - 📦 **E-Commerce Essentials** - Product listing, detail page - Cart functionality - Checkout skeleton (add your own payment provider) - 🛠️ **Database Ready** - Drop-in schema support with Drizzle - Easily seed with mock data --- ## 🗃️ Database Setup (Drizzle + Neon) Schema lives inside the `drizzle/schema` directory. - Run migrations: ```bash npx drizzle-kit push ``` - Preview schema or explore your tables using Neon dashboard or `psql`. --- ## 🧪 Testing (Optional) Coming soon: integration with Playwright and React Testing Library. --- ## 📦 Deployment - [ ] Ready for Vercel out of the box - [ ] Environment variables configured in the Vercel dashboard - [ ] You can also deploy via Docker or any Node host --- ## 📁 Project Structure `` /app → Next.js App Router pages /components → UI components /lib → Utils (auth, db, helpers) /drizzle → ORM schema and config /pages/api/auth → NextAuth configuration /public → Static assets /styles → Global styles (optional) `` --- ## 🙋 FAQ **Q: Can I use my own database?** Yes! As long as it’s PostgreSQL-compatible, just change `DATABASE_URL` and run `npx drizzle-kit push`. **Q: How do I add products?** Either use the mock data seed script or use your own admin interface / direct SQL insert. **Q: Can I add my own OAuth providers?** Yes, just update the `.env.local` and NextAuth config under `/pages/api/auth/[...nextauth].ts\`. --- ## 📬 Contributing Pull requests are welcome. For major changes, please open an issue first to discuss what you'd like to change. --- ## 📄 License MIT --- Made with ❤️ using Next.js, Drizzle, and Neon.
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

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

commerceplate
Commerceplate 是一个基于 Next.js 16、Tailwind CSS 4 和 TypeScript 的 Shopify 电商启动模板,由 Zeon Studio 开发并免费开源。
Next.js · 电商

ecommerce-template
An ecommerce template built with NextJS 16, TypeScript and TailwindCSS
Next.js · 电商

commercelayer-sanity-template
A multi-country ecommerce template built with Commerce Layer, Next.js, Sanity studio, and deployed to Netlify.
Next.js · 电商

boundless-nextjs-ecommerce-template
Next.js E-Commerce template. Strong TypeScript, Ready to use, For high-performance e-commerce websites.
Next.js · 电商

mobile-medusa
📱 Combine your Medusa.js e-commerce backend and/or web storefront with a Expo mobile app that matches Medusa …
Next.js · 电商
