公开商品目录支持分类、变体与搜索
ecommerce-template — Next.js 电商模板
作者 MarcosCamara01
基于 Next.js App Router 的电商模板,包含商品目录、登录后购物车与 Stripe 结账、订单历史,以及可与 Stripe 同步的后台商品管理。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
购物车、心愿单和订单数据绑定登录用户
Stripe Checkout 基于服务端购物车快照计价
后台商品管理与 Stripe 目录同步及失败重放
数据库采用 app_private 模式与最小权限角色
Vercel Cron 每 5 分钟执行履约与目录同步
模板详细介绍
这是一个面向电商场景的 Next.js 模板,使用 App Router、React 与 TypeScript 构建,UI 层采用 Tailwind CSS、Radix UI 和 TanStack Query。功能覆盖公开商品目录(分类、变体、搜索、帮助页)、需登录的购物车与心愿单、基于服务端购物车快照的 Stripe Checkout、订单历史与结果页,以及后台商品创建/编辑并与 Stripe 目录同步。数据层使用 Drizzle ORM 连接 Supabase PostgreSQL,采用 app_private 模式与最小权限角色布局;认证使用 Better Auth 的邮箱/密码方式,Google 登录为可选。模板还提供可选的订单确认与商家通知邮件(需显式配置 SMTP),以及每 5 分钟运行的 Vercel Cron 用于履约和目录同步。
使用前需要准备 Node.js 24、PostgreSQL 15 或更高版本(通常通过 Supabase)、Stripe 账户(开发时可用本地 Stripe 模拟器)。数据库需按顺序执行迁移、验证并提升首个管理员;README 明确 db:push 被禁用,应使用 db:generate 生成迁移再以 db:migrate 应用。生产构建会运行 verify:release 门禁,需要提供恢复演练、托管暴露报告和凭据轮换审计等证据文件。
模板的 MIT 许可仅覆盖仓库代码,演示图片、字体、图标等第三方素材需单独核对许可;Supabase、Stripe、托管、邮件等外部服务可能产生费用。
适合你的项目吗?
适用场景
- 搭建带商品目录与登录后购物车的电商前端
- 需要 Stripe Checkout 与服务端计价快照的结账流程
- 需要后台商品管理并与 Stripe 目录保持同步
- 需要订单历史、结果页与可选邮件通知的店铺
适合人群
- 熟悉 Next.js App Router 与 TypeScript 的开发者
- 使用 Supabase PostgreSQL 和 Stripe 的团队
- 需要最小权限数据库角色布局的电商项目
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
需要 Node.js 24、npm、PostgreSQL 15+(通常为 Supabase)和 Stripe 账户
- 2
复制 .env.example 到 .env.local 并填写数据库、认证、Stripe、Supabase 等变量
- 3
新数据库依次运行 npm run db:migrate、db:verify、auth:bootstrap-admin
- 4
db:push 被禁用,应使用 db:generate 生成迁移后以 db:migrate 应用
- 5
生产构建需通过 verify:release,需提供恢复演练、托管暴露与凭据轮换证据
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 使用 Stripe 结账与目录同步功能需要 Stripe 账户;开发环境可改用本地 Stripe 模拟器,但生产环境仍需真实 Stripe 账户与密钥。
- 需要 PostgreSQL 15 或更高版本数据库,通常通过 Supabase 提供;Supabase 托管服务可能产生费用。
- 订单确认与商家通知邮件默认关闭,必须显式配置 SMTP 主机及端口、账号、密码、发件人等参数后才可用。
- Google 登录为可选功能,需在 Google Cloud 注册回调并设置客户端 ID/密钥及两个启用标志,否则保持关闭。
- 生产构建会运行 verify:release 门禁,必须提供恢复演练、托管暴露报告与凭据轮换审计等证据文件,否则构建失败。
- 履约与目录同步依赖 Vercel Cron 每 5 分钟调用,且两个端点均需配置 CRON_SECRET,部署环境需支持定时任务。
- 托管数据库与存储应用需要 SUPABASE_ACCESS_TOKEN 和 SUPABASE_SERVICE_ROLE_KEY,涉及 Supabase 账户与访问令牌。
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
A Stripe account, or the local Stripe emulator for development
README 原文
PostgreSQL 15 or newer, typically via [Supabase](https://supabase.com)
README 原文
Delivery is disabled until `EMAIL_SERVER_HOST` names an explicit SMTP
README 原文
Google sign-in is opt-in. Register the exact callback
README 原文
Production builds run `npm run verify:release` and fail until
README 原文
Vercel crons call `/api/cron/fulfillment` and `/api/cron/catalog-sync` every
README 原文
https://github.com/MarcosCamara01/ecommerce-template/blob/master/LICENSEhttps://github.com/MarcosCamara01/ecommerce-template/blob/master/README.md`db:apply-hosted` uses the lockfile-pinned Supabase CLI to push
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-01。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 96 / 100
- 技术栈
- Next.js · React
- 网站类型
- 电商
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-09-28
- 截图检查日期
- 2026-10-01
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。
查看当时使用的来源资料
SHA-256: e015df6287d8de28af88a901d0e7e0fba54e50f744a3424330eb561547823117
2026-10-01T01:28:31.319Z
来源文件 / 仓库# Next.js Ecommerce Template Storefront starter with a public catalog, authenticated cart and checkout, Stripe fulfillment, and an admin catalog that stays in sync with Stripe. Built for App Router, a least-privilege Postgres layout, and a Principal-bound data layer. Live demo: [ecommerce-template-mpc.vercel.app](https://ecommerce-template-mpc.vercel.app) ## Stack | Layer | Choice | | --- | --- | | App | Next.js 16.3 (App Router, Cache Components), React 19, TypeScript | | UI | Tailwind CSS, Radix UI, TanStack Query | | Auth | Better Auth (email/password; Google is opt-in) | | Data | Drizzle ORM on Supabase PostgreSQL (`app_private`) | | Payments | Stripe Checkout (server-priced line items) | | Media | Supabase Storage (`product-images`: JPEG, PNG, WebP) | | Mail | Nodemailer over explicit SMTP (optional) | | Validation | Zod | Shared domain language lives in [`CONTEXT.md`](CONTEXT.md). Architecture and invariants are in [`docs/architecture/verifiable-auth-data-fulfillment.md`](docs/architecture/verifiable-auth-data-fulfillment.md). ## Features - Catalog with categories, variants, search, and help pages - Cart and wishlist (session required; data is scoped to the signed-in Principal) - Stripe Checkout from a server-built cart snapshot, not a client-supplied price - Order history and a result page that only loads a session the buyer owns - Admin product create/edit with Stripe catalog sync and replay for failed work - Background fulfillment and catalog-sync crons (Vercel, every 5 minutes) - Optional order-confirmation and merchant-notification email ## Prerequisites - Node.js 24 (what CI uses) and npm - PostgreSQL 15 or newer, typically via [Supabase](https://supabase.com) - A Stripe account, or the local Stripe emulator for development ## Getting started 1. Install dependencies: ```bash npm install ``` 2. Copy [`.env.example`](.env.example) to `.env.local` and fill the values described below. 3. For a **fresh** database, bootstrap roles, migrate, verify, then promote the first admin. For a **populated** database, follow the [database cutover runbook](docs/runbooks/database-cutover.md) instead of applying ad-hoc schema changes. ```bash npm run db:migrate npm run db:verify npm run auth:bootstrap-admin ``` 4. Start the app: ```bash npm run dev ``` 5. Open <http://localhost:3000>. `db:push` is disabled. Generate a reviewed migration with `db:generate`, apply it with `db:migrate`. ## Configuration Keep `NEXT_PUBLIC_APP_URL` and `BETTER_AUTH_URL` on the same canonical origin. `APP_URL` is an optional server-only override; when set, it must use that same origin. The complete list of variables is in `.env.example`. These are the ones that decide how the app boots: | Variable | Role | | --- | --- | | `DATABASE_URL` | Runtime connection as `app_runtime` | | `MIGRATION_DATABASE_URL` | `app_migrator`; `db:migrate` then assumes `app_owner` | | `VERIFY_DATABASE_URL` | Least-privileged connection for `db:verify` | | `AUTH_DATABASE_LAYOUT` | Must be `app_private` | | `BETTER_AUTH_SECRET` | Session signing secret | | `ADMIN_USER_ID` | Better Auth user id promoted by `auth:bootstrap-admin` | | `CRON_SECRET` | Bearer secret for `/api/cron/*` | | `STRIPE_SECRET_KEY`, `STRIPE_WEBHOOK_SECRET`, `NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY` | Stripe | | `NEXT_PUBLIC_SUPABASE_URL`, `NEXT_PUBLIC_SUPABASE_ANON_KEY`, `SUPABASE_SERVICE_ROLE_KEY` | Storage and project URL | | `SUPABASE_PROJECT_REF`, `SUPABASE_ACCESS_TOKEN` | Hosted Data API / Storage apply (`db:apply-hosted`) | `ADMIN_BOOTSTRAP_DATABASE_URL` is only for the temporary legacy-public cutover in the runbook. Do not put `role=` in `MIGRATION_DATABASE_URL`. ### Auth Email/password registration opens a session immediately. The app does not send or require a verification email, because SMTP is optional and often unset. Google sign-in is opt-in. Register the exact callback `http://localhost:3000/api/auth/callback/google` (and the HTTPS production equivalent) in Google Cloud, set `GOOGLE_CLIENT_ID` and `GOOGLE_CLIENT_SECRET`, then set both `GOOGLE_AUTH_ENABLED=true` and `NEXT_PUBLIC_GOOGLE_AUTH_ENABLED=true`. The server fails closed when the flags differ. Keep both `false` until the callback is registered. OAuth cannot reclaim or rewrite an unverified credential account. Linking another provider still requires the existing local account to be verified. Promote the first administrator by user id, not by email: ```bash ADMIN_USER_ID=<better-auth-user-id> npm run auth:bootstrap-admin ``` ### Email Delivery is disabled until `EMAIL_SERVER_HOST` names an explicit SMTP transport. A configured host also needs a valid port, user, password, sender (`EMAIL_FROM`), and contact recipient (`EMAIL_CONTACT_TO` or `ADMIN_EMAIL`). Partial configuration fails before Nodemailer creates a transport. Gmail can be used with its SMTP host; credentials alone never enable a Gmail fallback. Without SMTP, sign-up still works. Order confirmation and merchant notification emails do not. ### Local Stripe In development, set `STRIPE_EMULATOR_URL` to a loopback HTTP origin (no path, credentials, or query). Example: ```bash npx emulate --service stripe ``` Then point `STRIPE_EMULATOR_URL` at the emulator origin (default <http://localhost:4000> when Stripe runs alone). The variable is rejected in `NODE_ENV=production`. The live webhook endpoint is `/api/stripe/webhooks`. ## Scripts | Script | Purpose | | --- | --- | | `npm run dev` | Next.js dev server | | `npm run build` / `npm start` | Production build and server | | `npm test` | Node.js test runner | | `npm run lint` | ESLint | | `npm run typecheck` | `tsc --noEmit` | | `npm run verify:architecture` | Import-boundary and layering checks | | `npm run verify:release` | Production evidence gate | | `npm run db:generate` | Drizzle Kit migration | | `npm run db:migrate` | Role-aware migrator (`app_migrator` → `app_owner`) | | `npm run db:verify` | Schema and privilege verifier | | `npm run db:apply-hosted` / `db:verify-hosted` | Push and check Supabase Data API + `product-images` | | `npm run db:mark-cutover` | Record applied migrations after a cutover | | `npm run db:studio` / `db:pull` | Drizzle Kit as `app_owner` via the migrator session | | `npm run auth:bootstrap-admin` | Grant `admin` to `ADMIN_USER_ID` | | `npm run doctor` | React Doctor on the full tree | `db:migrate` authenticates as `app_migrator`, proves that role cannot run private DDL directly, then `SET ROLE app_owner` before applying the official Drizzle journal. `db:apply-hosted` uses the lockfile-pinned Supabase CLI to push `supabase/config.toml` to `SUPABASE_PROJECT_REF`, then verifies the Data API allowlist and the public `product-images` bucket (5 MiB, JPEG/PNG/WebP). It needs `SUPABASE_ACCESS_TOKEN` and `SUPABASE_SERVICE_ROLE_KEY`. The service-role key is withheld from the CLI config-push subprocess. ## Architecture `src/lib/identity` is the only request-credential boundary. It returns opaque user Principals (or purpose-limited system Principals for fulfillment and catalog sync). UI role checks are advisory; writes repeat the authoritative check. `src/lib/data-access` is the application interface to repositories. Public catalog reads are separate from Principal-bound cart, wishlist, order, checkout, and admin operations. Checkout persists a server-created snapshot (at most 100 lines). Stripe metadata holds only an opaque checkout-intent id. Fulfillment reconciles the charged amount against that snapshot; the live cart is never a fulfillment input. Webhooks record an event receipt and work row, then a worker (or the 5-minute cron) completes the order. ## Deployment - Set every required variable in the host (Vercel Production, Preview, and Development as needed). - Point Stripe webhooks at `https://<origin>/api/stripe/webhooks`. - Run `npm run db:migrate` before shipping code that depends on a new schema. - Never use `db:push`. - Production builds run `npm run verify:release` and fail until `RELEASE_CUTOVER_EVIDENCE`, `RELEASE_HOSTED_EXPOSURE_EVIDENCE`, and `RELEASE_CREDENTIAL_ROTATION_EVIDENCE` point at the approved restore rehearsal, hosted exposure report, and credential-rotation audit. - Vercel crons call `/api/cron/fulfillment` and `/api/cron/catalog-sync` every five minutes. Both require `CRON_SECRET`. ## CI Pull requests run `.github/workflows/ci.yml`: tests, a PostgreSQL 15 cutover rehearsal, typecheck, lint, architecture and release-gate checks, `next build`, and `npm audit` (all dependencies and production-only). ## License MIT. See [LICENSE](LICENSE).
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

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 · 电商

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 · 电商

template-ecommerce-webapp-nextjs
Next.js ecommerce website starter template
Next.js · 电商
