Next.jsReact电商启动器

turbo-start-shopify — Next.js 电商模板

作者 robotostudio

基于 Next.js、Shopify 与 Sanity 的无头电商启动模板,采用 Turborepo 单仓库结构,内置可视化编辑与类型安全的 Storefront API 集成。

看看你的网站会是什么样

浏览真实页面截图,比较内容排版与手机效果。点击下方缩略图切换,放大查看整页细节。

3 个预览视图
桌面端首页1 / 3
桌面端截图首屏预览

由服务器浏览器实际访问页面后截取。

全部页面与视图 3

截图用于了解视觉与布局,交互效果请以实际项目为准。

采集于 2026-10-02查看来源

值得关注的模板亮点

从已有项目资料中,快速了解它的特点。

01

Turborepo 单仓库结构,Web 应用与 Sanity Studio 分目录管理,共享环境校验、UI 与 Sanity 客户端等包

02

Shopify Storefront API 集成,覆盖商品、集合、购物车、结账与搜索

03

Sanity Studio 支持可视化编辑、实时预览、页面构建器,以及 slug 变更时自动重定向

04

端到端类型安全:自动生成 Sanity 类型、Zod 环境变量校验与严格 TypeScript

05

内置 SEO 相关能力,包括动态元数据、OG 图片、站点地图与 JSON-LD 结构化数据

06

提供 Sanity 种子数据与 Shopify 测试商品脚本,便于快速填充示例内容

模板详细介绍

这是一个无头电商启动模板,前端使用 Next.js App Router,商品与购物车数据来自 Shopify Storefront API,页面、博客、导航与 SEO 等内容由 Sanity CMS 管理。项目采用 Turborepo 单仓库结构,将 Web 应用、Sanity Studio 以及环境校验、Sanity 客户端、UI 组件、日志等拆分为独立包。模板提供可视化编辑与实时预览,商品数据在 Sanity Studio 中为只读,价格与变体需在 Shopify 后台修改。

使用前需要分别准备 Shopify 与 Sanity 账号:在 Shopify 侧创建 Dev 商店、安装 Headless 渠道并获取 Storefront API 访问令牌;在 Sanity 侧创建项目并生成读写令牌。商品需通过 Sanity Connect 应用从 Shopify 同步到 Sanity,否则商品页面会返回 404。仓库附带 Sanity 种子数据与 Shopify 测试商品脚本,可导入示例内容。

模板以 MIT 许可发布,可免费使用、修改与分发,但演示图片、字体等第三方素材需单独核对许可,域名、托管等外部服务可能产生费用。README 中提到的生产就绪表述属于项目自述,实际部署前应自行验证。

Next.js电商启动器

适合你的项目吗?

适用场景

  • 为品牌搭建以 Shopify 为交易后端、Sanity 为内容后台的无头电商站点
  • 在 Next.js App Router 项目中试验可视化编辑与实时预览工作流
  • 作为 Turborepo 单仓库电商项目的起始结构,按需扩展页面构建器区块与 Sanity schema
  • 用于学习 Shopify Storefront API 与 Sanity 内容同步的集成方式

适合人群

  • 熟悉 Next.js、TypeScript 与无头 CMS 概念的前端开发者
  • 需要将商品管理与内容编辑分离的电商团队
  • 希望以单仓库方式组织前端与 CMS Studio 的项目

上手与定制指南

结合仓库当前版本的说明,按下面的资料检查内容、配置与运行要求。

  1. 1

    需要 Node.js 与 pnpm,并准备 Shopify Partner 账号与 Sanity 账号

  2. 2

    在 Shopify 创建 Dev 商店并安装 Headless 渠道,获取 Storefront API 公共访问令牌与商店域名

  3. 3

    在 Sanity 创建项目与数据集,生成读、写 API 令牌,并复制示例环境变量文件填写

  4. 4

    导入 Sanity 种子数据,并通过 Sanity Connect 将 Shopify 商品同步到 Sanity,否则商品页面会 404

  5. 5

    部署 Next.js 时将 Vercel 根目录设为 apps/web,并配置全部必需环境变量

查看仓库使用说明

授权与来源资料

使用条件与限制

免费使用 · 保留许可声明

本次收录的是公开仓库中采用 MIT 许可的免费版本;免费范围为该版本代码,不代表外部服务或第三方素材免费。

使用时需要遵守

  • 允许免费使用、修改、商用和分发该版本代码。
  • 分发代码副本或实质性部分时,保留原作者版权声明和完整 MIT 许可声明。
  • 代码按现状提供;担保与责任限制以原许可证及适用法律为准。

额外费用与待核对事项

  • 使用前必须注册 Shopify Partner 账号,属于外部服务账号要求。
  • 使用前必须注册 Sanity 账号,属于外部服务账号要求。
  • 需在 Shopify 创建 Dev 商店,属于外部服务依赖。
  • 需安装 Shopify Headless 渠道并获取 Storefront API 访问令牌。
  • 需在 Sanity 创建项目,属于外部服务依赖。
  • 需在 Sanity 生成读写 API 令牌。
  • 商品同步依赖 Shopify 应用 Sanity Connect,需安装并配置。
  • 商品必须从 Shopify 同步到 Sanity,否则商品页面返回 404。
  • 种子脚本需在 Shopify Dev Dashboard 创建应用并授予 Admin API 权限。
  • Shopify Admin API 令牌仅 24 小时有效,过期需重新获取。
  • Shopify Dev 商店为永久测试商店,无法转为正式商店或转让给客户,仅限测试使用。
  • 正式商店需安装 Headless 渠道,且不得安装种子应用。
  • 可视化编辑需在浏览器启用第三方 Cookie。
  • 重定向在构建时从 Sanity 获取,新增重定向后需重新部署。
  • 演示图片、字体、图标及其他第三方素材需按各自许可核对,不能仅凭代码的 MIT 许可判断。
  • 域名、托管、数据库、支付或 AI 等外部服务可能另外收费。
查看原文依据

Permission is hereby granted, free of charge

许可证原文

A [Shopify Partner](https://www.shopify.com/partners) account

README 原文

A [Sanity](https://www.sanity.io/) account

README 原文

Create a **Dev** store in the [Dev Dashboard](https://dev.shopify.com/dashboard/) under **Stores > Create store**.

README 原文

install the [Headless](https://apps.shopify.com/headless) channel, add a storefront, turn on the inventory permission under **Storefront API permissions**, and copy its **public access token**

README 原文

Create a project at [sanity.io/manage](https://www.sanity.io/manage)

README 原文

Under **API > Tokens**, create a read token and a write token

README 原文

Install Sanity Connect in your Shopify store admin

README 原文

Products live in Shopify but the site also needs them in Sanity, or product pages return 404.

README 原文

Create an app in the Dev Dashboard with the Admin API scopes

README 原文

Tokens last 24 hours

README 原文

Dev stores are permanent. They cannot be converted to a live store or transferred to a client. Use one for testing only.

README 原文

Your live store needs the Headless channel too. Do not install the seed app on it.

README 原文

Enable third-party cookies in your browser.

README 原文

Redirects are fetched from Sanity at build time. Redeploy after creating new redirects.

README 原文
https://github.com/robotostudio/turbo-start-shopify/blob/main/LICENSEhttps://github.com/robotostudio/turbo-start-shopify/blob/main/README.md

DeepSeek 根据仓库许可证和 README 整理 ·2026-10-02。结果仅覆盖已读取资料,依赖、图片、字体及后续条款变更以各自原文为准。

项目核对记录与介绍依据

模板资料

来源平台
GitHub
资料与维护参考分
资料较完整 · 88 / 100
技术栈
Next.js · React
网站类型
电商 · 启动器
这个分数如何计算

本站按许可资料(最高30分)、演示链接(12分)、预览图(10分)、Star数(15分)、记录的维护时间(15分)、描述完整度(8分)、功能记录(5分)和分类资料(5分)计算。它不是代码、安全或性能测试,也不是 Google 评分;有链接不代表已实测可用。

这个项目需要核对什么

记录的仓库更新时间
2026-09-30
截图检查日期
2026-10-02

已收录演示链接。请用你的内容与屏幕尺寸检查;有演示不代表表单、认证或支付已经可用。

目录记录的主要技术栈是 Next.js。请通过依赖清单和锁文件核对实际版本与托管要求。这些说明基于收录资料,不代表代码审计或部署实测。

查看具体选型方法 →

介绍的制作与核对状态

介绍由 AI 辅助整理目录与仓库资料。仓库作者不等于这篇介绍的审核者。

已完成服务器许可规则与 AI 来源核对;未经过人工编辑审核。

查看当时使用的来源资料

SHA-256: b99304ae8474251006db7d07f950b896d72e290abd62dbb1b6f811f078c262f7

2026-10-02T07:31:09.487Z

来源文件 / 仓库
# Turbo Start Shopify

A production-ready headless commerce starter built with Shopify, Sanity, and Next.js — monorepo architecture with visual editing, type-safe data, and everything you need to ship fast.

Built by [Roboto Studio](https://robotostudio.com/services/shopify) and used in production client builds.

![Turbo Start Shopify](https://raw.githubusercontent.com/robotostudio/turbo-start-shopify/main/turbo-start-shopify-og.jpg)

**[Live demo →](https://turbo-start-shopify-web.vercel.app)**

[![Node.js](https://img.shields.io/badge/node-%3E%3D24.10-brightgreen)](https://nodejs.org/)
[![pnpm](https://img.shields.io/badge/pnpm-11.24-orange)](https://pnpm.io/)
[![Next.js](https://img.shields.io/badge/Next.js-16-black)](https://nextjs.org/)
[![Sanity](https://img.shields.io/badge/Sanity-v6-red)](https://www.sanity.io/)
[![Shopify](https://img.shields.io/badge/Shopify-Storefront%20API-green)](https://shopify.dev/docs/api/storefront)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)

## Features

- **Monorepo with Turborepo** — shared packages, fast builds, one `pnpm dev` to run everything
- **Next.js 16 App Router** — React Server Components, React Compiler, Turbopack, dynamic OG images
- **Sanity Studio v6** — visual editing, live preview, page builder, auto-redirects on slug change
- **Shopify Storefront API** — products, collections, cart, checkout, search
- **Type-safe end-to-end** — auto-generated Sanity types, Zod env validation, strict TypeScript
- **Tailwind CSS v4** — CSS-first config, OKLCH color tokens, dark mode, Shadcn components
- **SEO optimized** — dynamic metadata, OG images, sitemaps, JSON-LD structured data

## Architecture

### Data Flow

```
Shopify (products, collections, cart)
    ↕ Storefront API
Next.js 16 (App Router, RSC)
    ↕ GROQ queries via sanityFetch()
Sanity CMS (pages, blog, navigation, SEO)
```

### Monorepo Structure

```
apps/
  web/              → Next.js 16 frontend
  studio/           → Sanity Studio v6

packages/
  env/              → T3 env validation (Zod)
  sanity/           → Client, GROQ queries, live preview, generated types
  ui/               → Shadcn + Tailwind v4 primitives
  logger/           → Structured logger
  typescript-config/ → Shared TypeScript presets
```

## Prerequisites

- [Node.js](https://nodejs.org/) >= 24.10
- [pnpm](https://pnpm.io/) 11.24+
- A [Shopify Partner](https://www.shopify.com/partners) account
- A [Sanity](https://www.sanity.io/) account

## Getting Started

### 1. Clone and install

```bash
npx create-sanity@latest -- --template robotostudio/turbo-start-shopify
```

Or clone manually:

```bash
git clone https://github.com/robotostudio/turbo-start-shopify.git
cd turbo-start-shopify
pnpm install
```

### 2. Set up Shopify

> **Warning:** Dev stores are permanent. They cannot be converted to a live store or transferred to a client. Use one for testing only.

1. Create a **Dev** store in the [Dev Dashboard](https://dev.shopify.com/dashboard/) under **Stores > Create store**. Enable generated test data if you want sample products
2. In the store admin, install the [Headless](https://apps.shopify.com/headless) channel, add a storefront, turn on the inventory permission under **Storefront API permissions**, and copy its **public access token**
3. Note your **store domain** (e.g. `your-store.myshopify.com`)
4. (Optional, seed script only) Create an app in the Dev Dashboard with the Admin API scopes `write_products`, `read_products`, `read_locations`, `write_inventory`, `read_publications`, `write_publications`, `write_discounts`, `read_discounts`, install it on your store, then [get a token](https://shopify.dev/docs/apps/build/authentication-authorization/client-credentials-grant) from its Client ID and secret. Tokens last 24 hours

### 3. Set up Sanity

1. Create a project at [sanity.io/manage](https://www.sanity.io/manage)
2. Note your **project ID** and **dataset** name (default: `production`)
3. Under **API > Tokens**, create a read token and a write token

### 4. Configure environment variables

Copy the example files and fill in your values:

```bash
cp apps/web/.env.example apps/web/.env
cp apps/studio/.env.example apps/studio/.env
```

See the [Environment Variables Reference](#environment-variables-reference) below for all required values.

### 5. Seed content

Import the included Sanity seed data:

```bash
cd apps/studio
npx sanity dataset import ./seed-data.tar.gz production --replace
```

This seed has no products. Products come from Shopify. Skip this if you enabled generated test data in step 2, otherwise seed some:

```bash
pnpm seed:shopify
pnpm verify:shopify
```

Each run adds 10 fake products across 5 collections. Details in [`apps/studio/scripts/seed-shopify/README.md`](apps/studio/scripts/seed-shopify/README.md).

### 6. Sync products into Sanity

Products live in Shopify but the site also needs them in Sanity, or product pages return 404. The [Sanity Connect](https://apps.shopify.com/sanity-connect) app copies them across:

1. Install Sanity Connect in your Shopify store admin
2. Point it at your Sanity project and `production` dataset
3. Choose **Start synchronizing now**

Product data is read-only in the Studio. Edit prices and variants in Shopify; edit the surrounding content in Sanity.

### 7. Start development

```bash
pnpm dev
```

Open [http://localhost:3000](http://localhost:3000) for the Next.js app and [http://localhost:3333](http://localhost:3333) for Sanity Studio.

## Environment Variables Reference

### Web App (`apps/web/.env`)

| Variable | Required | Description |
|----------|----------|-------------|
| `NEXT_PUBLIC_SANITY_PROJECT_ID` | Yes | Your Sanity project ID |
| `NEXT_PUBLIC_SANITY_DATASET` | Yes | Sanity dataset name (e.g. `production`) |
| `NEXT_PUBLIC_SANITY_API_VERSION` | Yes | API version date (default: `2025-08-29`) |
| `NEXT_PUBLIC_SANITY_STUDIO_URL` | Yes | Studio URL (`http://localhost:3333` for dev) |
| `SANITY_API_READ_TOKEN` | Yes | Sanity API token with read access |
| `SANITY_API_WRITE_TOKEN` | Yes | Sanity API token with write access |
| `SHOPIFY_STORE_DOMAIN` | Yes | Your Shopify store domain (e.g. `your-store.myshopify.com`) |
| `SHOPIFY_STOREFRONT_ACCESS_TOKEN` | Yes | Shopify Storefront API public access token |
| `SHOPIFY_API_VERSION` | No | Storefront API version (default: `2025-01`) |
| `NEXT_PUBLIC_STORE_CURRENCY` | No | ISO 4217 code used to format prices (default: `GBP`) |
| `NEXT_PUBLIC_SITE_URL` | Off Vercel | Canonical origin, no trailing slash (e.g. `https://example.com`). On Vercel it is inferred; anywhere else, canonicals and the sitemap fall back to `localhost:3000` without it |

### Sanity Studio (`apps/studio/.env`)

| Variable | Required | Description |
|----------|----------|-------------|
| `SANITY_STUDIO_PROJECT_ID` | Yes | Same Sanity project ID as web |
| `SANITY_STUDIO_DATASET` | Yes | Same dataset name as web |
| `SANITY_STUDIO_TITLE` | Yes | Display title for the Studio |
| `SANITY_STUDIO_PRESENTATION_URL` | Prod | Frontend URL for live preview (auto-detects `localhost:3000` in dev) |
| `SANITY_STUDIO_PRODUCTION_HOSTNAME` | Deploy | Hostname for deployed Studio (e.g. `my-project` → `my-project.sanity.studio`) |
| `SANITY_STUDIO_API_VERSION` | No | Sanity API version |
| `SHOPIFY_STORE_DOMAIN` | Seeds | Your Shopify store domain (for seed scripts) |
| `SHOPIFY_ADMIN_ACCESS_TOKEN` | Seeds | 24-hour Admin API token from the client credentials grant in [step 2](#2-set-up-shopify) |

## Available Commands

| Command | Description |
|---------|-------------|
| `pnpm dev` | Start all apps (web on :3000, studio on :3333) |
| `pnpm dev:web` | Start Next.js only |
| `pnpm dev:studio` | Start Sanity Studio only |
| `pnpm build` | Build all apps |
| `pnpm build:web` | Build Next.js only |
| `pnpm build:studio` | Build Sanity Studio only |
| `pnpm lint` | Lint with Biome |
| `pnpm format` | Format with Biome |
| `pnpm format:check` | Check formatting without writing |
| `pnpm check-types` | TypeScript type checking across all packages |
| `pnpm seed:shopify` | Seed Shopify with test products |
| `pnpm verify:shopify` | Print Shopify store health report |

## Deployment

### Deploy Next.js to Vercel

1. Push your repo to GitHub
2. Create a new [Vercel](https://vercel.com/) project and connect your repository
3. Set the **Root Directory** to `apps/web`
4. Add all required environment variables from the [web app table](#web-app-appsweb-env) above
5. Deploy

### Deploy Sanity Studio

**Automatic (recommended):** The included GitHub Actions workflow (`.github/workflows/deploy-sanity.yml`) deploys your Studio automatically when changes are pushed to `apps/studio/`.

Add these secrets to your GitHub repository settings:

| Secret | Description |
|--------|-------------|
| `SANITY_DEPLOY_TOKEN` | Sanity deploy token |
| `SANITY_STUDIO_PROJECT_ID` | Sanity project ID |
| `SANITY_STUDIO_DATASET` | Dataset name |
| `SANITY_STUDIO_TITLE` | Studio display title |
| `SANITY_STUDIO_PRESENTATION_URL` | Your deployed frontend URL |
| `SANITY_STUDIO_PRODUCTION_HOSTNAME` | Studio hostname (e.g. `my-project` → `my-project.sanity.studio`) |

PR preview builds are created automatically — each PR gets its own Studio at `<branch-name>-<hostname>.sanity.studio`.

> **Note:** When initializing with the Sanity CLI, the `.github` folder may not be included. If missing, copy the workflows from the [template repository](https://github.com/robotostudio/turbo-start-shopify/tree/main/.github).

**Manual:**

```bash
cd apps/studio
npx sanity deploy
```

### Shopify Configuration

Your live store needs the Headless channel too. Do not install the seed app on it.

## Customization

### Adding a New Page Builder Block

1. Create a Sanity schema in `apps/studio/schemaTypes/blocks/`
2. Register it in `apps/studio/schemaTypes/blocks/index.ts`
3. Add a GROQ fragment in `packages/sanity/src/query.ts` and include it in `pageBuilderFragment`
4. Regenerate types: `pnpm --filter studio type`
5. Create a React component in `apps/web/src/components/sections/`
6. Register it in `BLOCK_COMPONENTS` in `apps/web/src/components/pagebuilder.tsx`
7. Add the type to `PageBuilderBlockTypes` in `apps/web/src/types.ts`

### Extending Sanity Schemas

- **Document types:** `apps/studio/schemaTypes/documents/`
- **Object types:** `apps/studio/schemaTypes/objects/`
- Register new types in `apps/studio/schemaTypes/index.ts`
- Always run `pnpm --filter studio type` after schema changes to regenerate types

### Adding Shadcn Components

Components live in `packages/ui/src/components/`. Follow the existing Radix + CVA pattern and import via `@workspace/ui/components/<component-name>`.

### Shopify Seed Scripts

```bash
pnpm seed:shopify                  # Append 10 test products
pnpm seed:shopify -- --batch=50    # Append 50 test products
pnpm seed:shopify -- --clean       # Delete EVERY product, collection and discount in the store
pnpm verify:shopify                # Print store health report
```

## Troubleshooting

| Problem | Solution |
|---------|----------|
| **"Module not found" errors** | Run `pnpm install` from the project root. Check path aliases in `tsconfig.json`. |
| **Sanity types out of date** | Run `pnpm --filter studio type` to regenerate. |
| **Visual editing not working** | Enable third-party cookies in your browser. Verify `SANITY_STUDIO_PRESENTATION_URL` is set. |
| **Shopify products not loading** | Verify `SHOPIFY_STORE_DOMAIN` and `SHOPIFY_STOREFRONT_ACCESS_TOKEN` are correct. |
| **Seed script fails** | Check that `SHOPIFY_ADMIN_ACCESS_TOKEN` has the required Admin API scopes and has not expired (tokens last 24 hours). |
| **Build fails on Vercel** | Ensure all env vars are set and the root directory is `apps/web`. |
| **Draft mode / live preview issues** | Confirm `SANITY_API_READ_TOKEN` is set with correct permissions. |
| **Tailwind styles not applying** | Ensure `@import "tailwindcss"` is in your CSS entry point. Check `@workspace/ui` transpile config. |
| **Redirects not working** | Redirects are fetched from Sanity at build time. Redeploy after creating new redirects. |

## Tech Stack

| Technology | Version | Purpose |
|------------|---------|---------|
| [Next.js](https://nextjs.org/) | 16 | React framework (App Router, RSC, Turbopack) |
| [React](https://react.dev/) | 19 | UI library |
| [Sanity](https://www.sanity.io/) | 6 | Headless CMS with visual editing |
| [Shopify Storefront API](https://shopify.dev/docs/api/storefront) | 2025-01 | Commerce engine |
| [Turborepo](https://turbo.build/) | 2 | Monorepo build orchestration |
| [Tailwind CSS](https://tailwindcss.com/) | 4 | Utility-first CSS framework |
| [Shadcn UI](https://ui.shadcn.com/) | — | Accessible component primitives |
| [Biome](https://biomejs.dev/) | 2 | Linter and formatter |
| [TypeScript](https://www.typescriptlang.org/) | 5 | Type safety |
| [Zod](https://zod.dev/) | 4 | Runtime env validation |
| [pnpm](https://pnpm.io/) | 11 | Package manager |

## Contributing

See [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines on how to contribute to this project.

## License

[MIT](LICENSE) &copy; [Roboto Studio](https://robotostudio.com)
反馈内容错误

看看同类模板

对比同技术栈与用途的模板,找到更适合的视觉与内容结构。