Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

commercelayer-sanity-template

> 前端框架
Open source

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

188 stars0 likes2 views
WebsiteGitHub

About

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

Commerce Layer Sanity Template

A multi-country ecommerce template built with Commerce Layer, Nextjs, Sanity studio, and deployed to Netlify. Want to learn more about how we built the first version of this template and how you can build yours? Then you should read this article on our blog.


Table of Contents

  • Commerce Layer Sanity Template
    • Table of Contents
    • Template Features
    • Important Files and Folders
    • Getting Started
      • Installation Guide
      • Import Seed Commerce Layer Data
      • Import Seed Sanity Studio Content
      • Add Custom Commerce and Content Data
    • Contributors Guide
    • Need Help?
    • License

Template Features

  • A user-friendly and performant ecommerce storefront (with products, categories, i18n, cart, checkout, etc.) built with TypeScript, Nextjs, Commerce Layer React Components library, and Tailwind CSS.
  • International transactional functionalities powered by Commerce Layer API.
  • Structured content and a customizable Sanity authoring environment (including demo data), accessible on /studio.
  • PSD2-compliant and production-ready checkout functionality powered by Commerce Layer React Checkout application.
  • Commerce seed data powered by Commerce Layer CLI Seeder plugin.
  • React19 and Next16 support.
  • Type-checking and code linting.
  • Localization support (including Italian and French translations).
  • SEO and progressive web application (PWA) support.
  • Comprehensive installation and usage documentation.
  • One-click deployment configuration to Netlify.
Storefront (/ page) Sanity studio (/studio page)

Important Files and Folders

Path Description
.env.local.example Example file with all the required environment variables.
/components React components for the storefront.
/locale/index.ts Config file for the storefront's transalations (en-US, it-IT, and fr-FR).
/hooks/GetToken.ts React hook file to fetch a salesChannel token from Commerce Layer and save as a cookie.
/pages/[countryCode]/[lang]/index.tsx Index page for the storefront (country selector and product listing).
/pages/[countryCode]/[lang]/[product].tsx Page for all product items (image, product information, and variant selection).
/pages/[countryCode]/[lang]/cart.tsx Cart page for for the storefront with link to checkout.
/data Exported data to seed your Sanity studio with.
/utils/sanity/api.ts Where all data from Sanity is fetched using groq queries.
sanity.config.ts Config file for Sanity Studio.
sanity.cli.ts Config file for Sanity CLI.
/pages/studio/[[...index]].tsx Where Sanity Studio is mounted using next-sanity.
/schemas Where Sanity Studio gets its content types from.
/plugins Where the advanced Sanity Studio customization is setup.
next.config.mjs Config file for Next.js.
eslint.config.mjs ESLint flat config file for code linting.

Getting Started

The quickest way to get up and running is to use the deploy button below to set up and deploy automatically to Netlify. Afterward, you will add some seed data to Commerce Layer and Sanity studio. The deploy button will clone this repository and ask you to enter all the required environment variables. Alternatively, you can clone this repository, configure the template, import the dataset into your Sanity studio, import some seed commerce data into your Commerce Layer organization, and deploy your application. The installation guides below will show you how to achieve this.

Installation Guide

  1. Clone this repository (learn how to do this).

  2. Rename the .env.local.example file to .env.local and add the following credentials:

Variable Description
BUILD_LANGUAGES The supported locales (the default is en-US, it-IT, fr-FR).
NEXT_PUBLIC_SITE_NAME Optional name for the `` head tag (you can also edit this directly in the code).
NEXT_PUBLIC_SITE_URL Optional URL of your deployed project for the og:url meta property (you can also edit this directly in the code).
NEXT_PUBLIC_CL_CLIENT_ID Your Commerce Layer sales channels application client ID (you can create this automatically by following this onboarding guide or manually on the Commerce Layer dashboard.
NEXT_PUBLIC_CL_ENDPOINT Your Commerce Layer organization's base endpoint (you can copy this on the Commerce Layer dashboard.
NEXT_PUBLIC_SANITY_PROJECT_TITLE Optional name for the `` head tag in Sanity studio (you can also edit this directly in the code).
NEXT_PUBLIC_SANITY_PROJECT_ID Sanity project ID (you can get this from sanity.io/manage after creating a new project with the npm create sanity@latest CLI command or this quick start wizard.
NEXT_PUBLIC_SANITY_DATASET Sanity dataset (you can get this from sanity.io/manage).
NEXT_PUBLIC_SANITY_API_VERSION Sanity API version in the ISO date format, e.g 2026-09-14 (you can learn more about this in Sanity docs). According to the docs this can be set to today's date in UTC format to get the latest features.
NEXT_PUBLIC_SANITY_TOKEN Sanity API token (you can get this from sanity.io/manage).
  1. Run the command below to install the required dependencies:
bash
pnpm install
  1. Run the command below to start the development server:
bash
pnpm run dev

This will run the storefront at localhost:3000 and studio at localhost:3000/studio.

  1. Other available scripts:
Command Description
pnpm run build Builds the application for production.
pnpm start Starts the production server (run pnpm run build first).
pnpm run check Lints the codebase with ESLint.
pnpm run check:fix Formats the codebase with Prettier and fixes the linting errors.
pnpm run format Formats the codebase with Prettier.
pnpm run export Exports the Sanity production dataset to /data.

Import Seed Commerce Layer Data

  1. Create a free Commerce Layer account. If you already have an active account, kindly skip to Step 3.

  2. Create a new organization or follow the onboarding tutorial guide.

  3. Create a new Integrations application with Name set to CLI and Role set to admin.

  4. In your newly created application, copy the Client ID, Client secret, and Base endpoint credentials.

  5. Install the Commerce Layer CLI which is available as an npm package or yarn package using the command below:

bash
//npm
npm install -g @commercelayer/cli

//yarn
yarn global add @commercelayer/cli
  1. Log into your application via the CLI using the previously cr

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptcommercelayerecommercenextjsreactjs

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架