Next.js App Router 店面,包含首页、/shop 与 /shop/[slug] 商品页、购物车和多步结账
medusa-nextjs-ecom-kit — Next.js 电商模板
作者 floating-astronaut
基于 Medusa 2.x 后端与 Next.js App Router 的开源无头电商起步套件,已包含商品目录、购物车、多步结账、客户账户、订单邮件与可选分析埋点,使用 TypeScript 和 Tailwind CSS 编写。
看看你的网站会是什么样
浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。
全部页面与视图 2
截图用于了解视觉与布局,交互效果请以实际项目为准。
值得关注的模板亮点
从已有项目资料中,快速了解它的特点。
Medusa 2.x 无头后端,管理商品、变体、定价、库存、区域,并提供管理后台
客户账户区域 /account/*,支持注册、登录、资料与订单历史
订单各阶段事务性邮件(已下单、付款、已发货、已送达、已取消),通过 Nodemailer 对接任意 SMTP 服务
环境变量驱动的品牌配置,名称、配色、货币、社交与政策文案集中在 brand.ts
内置 SEO 相关输出:元数据、JSON-LD、sitemap.xml、robots.txt 与 llms.txt
模板详细介绍
该模板是一个无头电商起步套件,前端为 Next.js App Router 店面,后端为 Medusa 2.x,数据库使用 PostgreSQL。README 说明其已接好商品目录、购物车、多步结账、客户注册登录与订单历史、订单各阶段的事务性邮件,以及可选的 Google Analytics 与 Meta Pixel / Conversions API。品牌信息(名称、配色、货币、社交链接、政策文案)通过环境变量与 src/config/brand.ts 驱动,多数外观改动无需改代码。
结账部分提供两条与支付服务商无关的路径:银行转账为手动付款流程,下单后生成付款参考并发送邮件;占位(演示)支付路由会把订单标记为已支付并跳转成功页,README 明确说明它不产生真实扣款,不可用于真实收款。要接入真实支付,需在 src/app/api/payments/ 中替换占位实现,并在服务端接入所选支付服务商。
README 未提供性能、并发、安全加固或生产环境运维方面的说明;模板自带的是中性占位品牌与商品数据,需要自行替换。
适合你的项目吗?
适用场景
- 需要一个可运行的无头电商起点,而不是从空白页面搭建商品、购物车与结账流程
- 希望用 Medusa 管理商品、库存与区域,用 Next.js 构建定制店面
- 需要客户账户与订单历史,并为订单各阶段自动发送邮件
- 在接入真实支付服务商前,先用银行转账或演示支付跑通完整下单流程
- 通过环境变量快速替换品牌信息,把同一套代码用于不同店铺
适合人群
- 熟悉 Next.js 与 TypeScript、希望自建店面的开发者
- 计划使用 Medusa 作为无头电商后端的团队
- 需要可自行替换支付与邮件服务商的中立起步项目
- 愿意自行准备 PostgreSQL 并按 README 完成部署的开发者
上手与定制指南
结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。
- 1
前置条件:Node 20+、一个 PostgreSQL 数据库,可选 Redis
- 2
后端:进入 medusa/ 目录,复制 .env.template 为 .env 并填写 DATABASE_URL 等,执行 npm install、npx medusa db:migrate、npm run seed、npm run dev,Medusa 运行在 9000 端口,管理后台位于 /app
- 3
前端:在仓库根目录复制 .env.example 为 .env.local,填入从 Medusa 管理后台获取的 MEDUSA_PUBLISHABLE_KEY 与 MEDUSA_REGION_ID,执行 npm install 和 npm run dev,店面运行在 3000 端口
- 4
build-all.sh 可一次性构建后端与前端
- 5
支付:银行转账为手动流程;占位(演示)路由不产生真实扣款,接入真实收款需替换 src/app/api/payments/ 中的占位实现
授权与来源资料
使用条件与限制
免费使用 · 保留许可声明本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。
使用时需要遵守
- 允许免费使用、修改、商用和分发该版本代码。
- 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
- 代码按现状提供;担保与责任限制以原许可证及适用法律为准。
额外费用与待核对事项
- 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
- 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
- 占位(演示)支付路由仅用于演示,不产生真实扣款,不可用于真实收款;接入真实支付需自行替换占位实现。
- 结账流程可在不注册任何支付服务的情况下跑通,但真实收款需自行接入支付服务商。
- 运行需要 Node 20+ 与一个 PostgreSQL 数据库,Redis 为可选。
- 需要从 Medusa 管理后台获取 MEDUSA_PUBLISHABLE_KEY 与 MEDUSA_REGION_ID 并填入 .env.local。
- 模板自带的是中性占位品牌与商品数据,需自行替换为实际内容。
- Google Analytics 与 Meta Pixel / Conversions API 分析埋点为可选功能。
查看原文依据
Permission is hereby granted, free of charge
许可证原文
**No real charge — do not use it to take real money.**
README 原文
runnable **without signing up for anything**:
README 原文
**Prerequisites:** Node 20+, a PostgreSQL database, and (optionally) Redis.
README 原文
Get `MEDUSA_PUBLISHABLE_KEY` and `MEDUSA_REGION_ID` from the Medusa admin
README 原文
> This template ships neutral placeholder branding and products for you to
README 原文
https://github.com/floating-astronaut/medusa-nextjs-ecom-kit/blob/main/LICENSEhttps://github.com/floating-astronaut/medusa-nextjs-ecom-kit/blob/main/README.md| 📈 **Analytics** | Optional Google Analytics + Meta Pixel / Conversions API |
README 原文
DeepSeek 根据仓库许可证和 README 整理 ·2026-10-15。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。
项目核对记录与介绍依据
模板资料
- 来源平台
- GitHub
- 资料与维护参考分
- 资料较完整 · 88 / 100
- 技术栈
- Next.js · React
- 网站类型
- 电商 · 启动器
这个分数如何计算
本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。
这个项目需要核对什么
- 记录的仓库更新时间
- 2026-10-05
- 截图检查日期
- 2026-10-15
已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。
目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。
查看具体选型方法 →介绍的制作与核对状态
介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。
审核声明: codex-user-requested-batch-review-20261015 · 2026-10-15
查看当时使用的来源资料
SHA-256: 60a6e93add8b1b88c3d0b40aac58dede5fe3bf3911b588a6dcdd27a53a9330d1
2026-10-15T00:18:46.626Z
来源文件 / 仓库<div align="center">
# Medusa + Next.js E-commerce Kit
### An open-source, production-shaped headless commerce starter — a **Next.js 16** storefront on a **Medusa 2.x** backend.
Cart, checkout, customer accounts, order history, product catalog, transactional
email, and analytics — already wired together, so you start from a working store
instead of a blank page.
[](https://nextjs.org/)
[](https://react.dev/)
[](https://medusajs.com/)
[](https://www.typescriptlang.org/)
[](https://tailwindcss.com/)
[](https://www.postgresql.org/)
[](./LICENSE)
[](#contributing)
**🔗 Live demo:** **[exotic420budz.com](https://exotic420budz.com/)** — a real store running on this exact stack.
</div>
---
## Table of contents
- [Why this kit](#why-this-kit)
- [Features](#features)
- [Architecture](#architecture)
- [Tech stack](#tech-stack)
- [Quick start](#quick-start)
- [Checkout & payments](#checkout--payments)
- [Project structure](#project-structure)
- [Make it yours](#make-it-yours)
- [Deployment](#deployment)
- [Contributing](#contributing)
- [License](#license)
---
## Why this kit
Most headless-commerce tutorials stop at "hello products". This one ships the
parts that are actually annoying to build: a real multi-step **checkout**, a
**customer account** area with order history, **transactional email** for every
order stage, an **analytics** layer, and env-driven **branding** so one codebase
can become any store. It is intentionally provider-agnostic — swap in Stripe,
PayPal, or any gateway when you're ready to take money.
> This template ships neutral placeholder branding and products for you to
> replace with your own.
---
## Features
| | |
|---|---|
| 🛍️ **Storefront** | Home, catalog (`/shop`, `/shop/[slug]`), cart, and a multi-step checkout |
| 👤 **Customer accounts** | Register, login, profile, and order history (`/account/*`) |
| 💳 **Checkout & payments** | Generic **bank-transfer** flow + a **placeholder (demo)** payment route — provider-agnostic |
| 📧 **Transactional email** | Order-received, payment, shipped, delivered & canceled emails via any SMTP provider |
| 🎨 **Env-driven branding** | Name, colours, currency, socials & policy copy in one `brand.ts` — no code edits |
| 🔎 **SEO out of the box** | Metadata, JSON-LD, `sitemap.xml`, `robots.txt`, and `llms.txt` |
| 📈 **Analytics** | Optional Google Analytics + Meta Pixel / Conversions API |
| 🧱 **Headless backend** | Medusa 2.x: products, variants, pricing, inventory, regions, admin dashboard |
| 🧑💻 **Typed end-to-end** | TypeScript everywhere, `tsc --noEmit` clean |
---
## Architecture
```mermaid
flowchart LR
subgraph Client["🌐 Browser"]
U["Shopper"]
end
subgraph Storefront["▲ Next.js 16 storefront"]
direction TB
Pages["App Router pages<br/>shop · cart · checkout · account"]
API["Route handlers<br/>/api/orders · /api/payments · /api/webhooks"]
end
subgraph Backend["🟣 Medusa 2.x backend"]
direction TB
Store["Store & Admin API"]
Admin["Admin dashboard"]
end
DB[("🐘 PostgreSQL")]
Mail["✉️ SMTP / email"]
Analytics["📈 GA · Meta Pixel"]
U --> Pages
Pages --> API
Pages -->|products, cart| Store
API -->|draft orders, payments| Store
Store --> DB
Admin --> DB
API --> Mail
Pages --> Analytics
```
---
## Tech stack
| Layer | Technology |
|---|---|
| Storefront | Next.js 16 (App Router) · React 19 · TypeScript 5 |
| Styling | Tailwind CSS 4 |
| Backend | Medusa 2.13 (headless commerce) |
| Database | PostgreSQL |
| Email | Nodemailer (any SMTP / transactional provider) |
| Tooling | ESLint 9 · Corepack / pnpm (backend) · npm (storefront) |
---
## Quick start
**Prerequisites:** Node 20+, a PostgreSQL database, and (optionally) Redis.
```bash
# 1. Backend (Medusa) — in the medusa/ folder
cd medusa
cp .env.template .env # fill in DATABASE_URL etc.
npm install
npx medusa db:migrate
npm run seed # loads the placeholder catalog
npm run dev # Medusa on http://localhost:9000 (admin at /app)
# 2. Storefront (Next.js) — in a second terminal, from the repo root
cp .env.example .env.local # set MEDUSA_* keys from your Medusa instance
npm install
npm run dev # storefront on http://localhost:3000
```
Get `MEDUSA_PUBLISHABLE_KEY` and `MEDUSA_REGION_ID` from the Medusa admin
(**Settings → Publishable API Keys**, and **Settings → Regions**) and paste them
into `.env.local`.
> 💡 `build-all.sh` builds both the backend and the storefront in one shot.
---
## Checkout & payments
The kit ships two provider-agnostic payment paths so checkout is complete and
runnable **without signing up for anything**:
- **Bank Transfer** — a manual-payment flow. The order is created, a payment
reference is generated, and the customer is emailed account details to
complete the transfer.
- **Placeholder (Demo)** — creates the order and marks it paid via
`/api/payments/placeholder`, then lands on `/checkout/success`.
**No real charge — do not use it to take real money.**
```mermaid
sequenceDiagram
actor C as Shopper
participant SF as Next.js checkout
participant O as /api/orders
participant P as /api/payments/placeholder
participant M as Medusa backend
participant E as Email
Note over C,E: Bank Transfer flow
C->>SF: Choose "Bank Transfer"
SF->>O: POST order (bank_transfer)
O->>M: Create draft order
O->>E: Email payment reference + details
O-->>SF: paymentReference, payToEmail
SF-->>C: Show bank-transfer instructions
Note over C,E: Placeholder (Demo) flow
C->>SF: Choose "Placeholder (Demo)"
SF->>O: POST order (placeholder)
O->>M: Create draft order
SF->>P: POST { storefrontOrderId }
P->>M: Convert draft → order, mark paid
P-->>SF: ok
SF-->>C: Redirect to /checkout/success
```
### Going live
Replace the placeholder in [`src/app/api/payments/`](src/app/api/payments/) with
your provider of choice. Medusa has first-party support for Stripe and others;
wire the provider **server-side** and point the checkout's payment step at it.
Search the code for `PAYMENT_PROVIDER` and the `placeholder` payment route for
the seams.
---
## Project structure
```
.
├── src/ # Next.js storefront (App Router)
│ ├── app/ # routes: shop, cart, checkout, account, content, api/
│ ├── components/ # UI components
│ ├── config/brand.ts # env-driven brand config (single source of truth)
│ ├── data/ # product fetch/shape helpers
│ └── lib/ # medusa client, mailer, shipping, payment helpers
├── medusa/ # Medusa 2.x backend
│ └── src/
│ ├── api/ # custom API routes
│ ├── modules/ # custom modules
│ ├── subscribers/ # event subscribers (order lifecycle → email)
│ ├── workflows/ # custom workflows
│ └── scripts/seed.ts # placeholder catalog seed
├── public/ # static assets / images
├── scripts/ # ops helpers (deploy, stale-draft cleanup)
├── build-all.sh # build backend + storefront
└── .env.example # storefront env template
```
---
## Make it yours
| To change… | Edit |
|---|---|
| Store name, tagline, colours, currency, socials | `.env.local` / `.env` (see [`src/config/brand.ts`](src/config/brand.ts)) |
| Products | Medusa admin, or [`medusa/src/scripts/seed.ts`](medusa/src/scripts/seed.ts) |
| Home / about / FAQ / policies copy | `src/app/*/page.tsx` |
| Logo & imagery | `public/` |
| Payment provider | [`src/app/api/payments/`](src/app/api/payments/) |
Branding is intentionally env-driven — for most cosmetic changes you only touch
`.env`, no code.
---
## Deployment
- **Storefront** — deploys to any Node host or Vercel. Set the same env vars
from `.env.example` in your host's dashboard.
- **Backend** — deploy Medusa to any Node host with a managed PostgreSQL (and
optional Redis). See the [Medusa deployment docs](https://docs.medusajs.com/deployments).
- Point the storefront's `MEDUSA_BACKEND_URL` at your deployed backend.
---
## Contributing
Issues and PRs are welcome. Please keep changes typed (`npx tsc --noEmit` must
stay clean) and run `npm run lint` before opening a PR. See
[CONTRIBUTING.md](./CONTRIBUTING.md) for the full guide.
---
## License
[MIT](./LICENSE) © Tejas Karan Agrawal. Use it, fork it, ship your store.
---
<div align="center">
*Built from a real, live storefront and opened up as a starting point.*
**If it saved you time, a ⭐ is appreciated.**
</div>
看看同类模板
对比同技术栈与用途的模板,找到更适合的视觉与内容结构。

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 · 启动器
