Sanity Photon is a minimal starter kit for building custom e-commerce experiences with a headless architecture. It combines the power of Shopify for commerce operations, Sanity for content management, and Next.js for a fast, SEO-friendly storefront.
- Next.js App Router - Statically generated pages for speed, SEO, and cost-efficiency
- Sanity Studio - Visual editing with real-time preview for all your content
- Shopify Integration - Leveraging Shopify's commerce infrastructure for products, payments, shipping, etc.
- Page Builder - Create and customize editorial, collection, and product pages
- Real-time Updates - Sanity Live API and Shopify-Sanity sync with automatic fine-grained revalidation
- Klaviyo Integration - Email list management for your marketing needs
- Minimal Styling - Intentionally lightweight CSS for maximum customization flexibility
- TypeScript - Full type safety throughout the codebase
- Node.js 18.17 or later
- Shopify Partner account with a store
- Sanity account
- (Optional) Klaviyo account for email marketing
-
Clone the repository:
git clone https://github.com/soufDev/sanity-photon.git cd sanity-photon -
Install dependencies:
npm install -
Set up environment variables:
- Copy
.env.examplefiles in bothstudioandstorefrontdirectories to create.envfiles - Fill in the required values (see Configuration section below)
- Copy
-
Start the development environment:
npm run dev
This will start both the Sanity Studio (http://localhost:3333) and the Next.js storefront (http://localhost:3000).
- Create a new Sanity project at sanity.io/manage
- Get your Project ID from the project dashboard
- Create an API token with read permissions
- Add these to the respective
.envfiles:
# studio/.env
SANITY_STUDIO_PROJECT_ID="your-project-id"
SANITY_STUDIO_DATASET="production"
# storefront/.env
NEXT_PUBLIC_SANITY_PROJECT_ID="your-project-id"
NEXT_PUBLIC_SANITY_DATASET="production"
NEXT_PUBLIC_SANITY_API_VERSION="2024-01-01" # Use current or future date
SANITY_API_READ_TOKEN="your-read-token"
- Set up a Shopify store (or use an existing one)
- Create a custom app in your Shopify Admin (Apps > Develop apps > Create an app)
- Set up the Storefront API permissions
- Generate a Storefront API token
- Add Shopify variables to
storefront/.env:
SHOPIFY_STOREFRONT_ACCESS_TOKEN="your-token"
SHOPIFY_STORE_ID="your-store-id"
SHOPIFY_STORE_DOMAIN="your-store-id.myshopify.com"
NEXT_PUBLIC_SHOPIFY_STORE_DOMAIN="your-store-id.myshopify.com"
If you want to use Klaviyo for email list management:
- Create a Klaviyo account and get your Public API Key
- Add to
storefront/.env:
KLAVIYO_PRIVATE_API_KEY="your-klaviyo-api-key"
/studio- Sanity Studio configuration and schemas/storefront- Next.js frontend application/app- Routes and application components/components- Reusable UI components/sanity- Sanity client and queries/shopify- Shopify integration logic
- Products & Collections: Managed in Shopify, synced to Sanity
- Content: Managed in Sanity Studio
- Cart & Checkout: Handled by Shopify Storefront API
- Front-end: Next.js consumes data from Sanity's API, which includes the synced Shopify data
The project uses CSS Modules for styling. You can:
- Continue using the CSS Modules approach
- Integrate Tailwind CSS
- Add any other styling solution you prefer
Modify the Sanity schema in /studio/src/schemas to adapt the content model to your needs.
Customize UI components in /storefront/components to match your brand's design.
Deploy Sanity Studio to Sanity's hosting with:
cd studio
npx sanity deploy
The storefront can be deployed to Vercel, Netlify, or any other Next.js-compatible hosting:
# For Vercel
vercel
# For production
vercel --prod
- Internationalization (i18n) support
- Product listing page (PLP) filters
- Redirect/rewrites functionality
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Created with love by Soufiane El Jazouli
