Sanity Market - E-Commerce Monorepo
This is Running Live in Production: Built with Sanity, Shopify Hydrogen, Sanity Functions, and Sanity SDK Apps. This monorepo provides a complete headless commerce solution with advanced content management, real-time notifications, and automated marketing campaigns.
View the live Sanity Market
This repository contains multiple interconnected systems:
- ๐ Frontend: React Router-based Hydrogen storefront
- ๐ Studio/CMS: Sanity Studio for content management
- โก Functions: Serverless functions for automation
- ๐ฑ Apps: Custom Sanity SDK applications
- ๐ Integrations: Shopify, Algolia, and Klaviyo
swag-store/
โโโ web/ # Hydrogen storefront (React Router)
โโโ sanity/ # Sanity Studio CMS
โโโ functions/ # Sanity Functions (serverless)
โโโ sanity-apps/ # Custom Sanity SDK Apps
โ โโโ notifications/ # Notification management app
โโโ data/ # Sample data and fixtures
โโโ docs/ # Documentation and guides
- Node.js 18+ (required by Hydrogen)
- pnpm 10.12.4+ (package manager)
- Shopify CLI ~3.85.4 (for Hydrogen development)
- Sanity CLI (for CMS management)
- TypeScript 5.2.2+ (for type checking)
-
Clone the repository
git clone <repository-url> cd swag-store
-
Install dependencies
pnpm install
-
Set up environment variables
# Copy environment templates cp web/.env.example web/.env cp sanity/.env.example sanity/.env -
Configure your environment
- Update
web/.envwith Shopify credentials - Update
sanity/.envwith Sanity project details - Configure function environment variables
- Update
Start all services in development mode:
# Start everything (web + sanity + functions)
pnpm dev
# Or start individual services
pnpm dev:web # Hydrogen storefront (with codegen)
pnpm dev:sanity # Sanity Studio
# Additional development commands
pnpm typecheck # Run TypeScript type checking
pnpm lint # Run ESLint
pnpm codegen # Generate GraphQL types and Sanity typesLocation: web/
A modern e-commerce storefront built with Shopify Hydrogen and React Router v7.
- ๐๏ธ Product Catalog: Dynamic product listings and collections
- ๐ Internationalization: Multi-language and multi-currency support
- ๐ฑ Responsive Design: Mobile-first responsive layout
- โก Performance: Optimized for Core Web Vitals
- ๐จ Custom Components: Reusable UI components and layouts
- Framework: Shopify Hydrogen 2025.7.0
- Routing: React Router 7.9.2 (file-based routing)
- Styling: Tailwind CSS 4.1.6
- State Management: React Context + Hooks
- Data Fetching: GraphQL + GROQ queries
- React: 18.3.1
- TypeScript: 5.2.2
The application uses React Router v7's file-based routing system with locale support:
($locale)._index.tsx- Homepage with featured content($locale).products.$handle.tsx- Product detail pages($locale).collections.$handle.tsx- Collection pages($locale).collections._index.tsx- Collections listing($locale).collections.all.tsx- All products page($locale).pages.$handle.tsx- CMS-managed pages($locale).cart.tsx- Shopping cart($locale).cart.$lines.tsx- Cart line items($locale).policies.$handle.tsx- Policy pages($locale).newsletter.ts- Newsletter subscription($locale).subscribe.tsx- Subscription management($locale).discount.$code.tsx- Discount code handling[robots.txt].tsx- SEO robots fileapi.preview.ts- Sanity preview API
Location: sanity/
A powerful content management system with custom schemas and workflows built with Sanity v4.10.1.
- Products: Shopify-synced product data
- Collections: Product groupings and categories
- Pages: Custom CMS pages and content
- Emails: Craft marketing campaigns for Klaviyo
- Marketing Campaigns: Campaign management
- Notifications: System notifications
- Settings: Site-wide configuration
- ๐ Shopify Sync: Automatic product synchronization
- ๐ Analytics: Built-in content analytics with Sanity Assist
- ๐ฏ Hotspots: Interactive image hotspots with custom plugin
- ๐ฑ Preview: Live preview of content
- ๐ง Custom Actions: Automated content workflows
- ๐ค AI Assist: Content generation and optimization
- ๐ธ Media Management: Advanced asset handling with custom plugin
- ๐๏ธ Back in Stock Management: Custom Back in Stock syncing + Customer management
- Custom Inputs: Specialized input components
- Document Actions: Automated workflows
- Media Management: Advanced asset handling
- Validation: Content validation rules
- Permissions: Role-based access control
Location: functions/
Serverless functions for automation and integrations.
| Function | Purpose | Trigger |
|---|---|---|
algolia-sync |
Sync products to Algolia search | Product updates |
marketing-campaign-create |
Create marketing campaigns | Manual/API |
marketing-campaign-send |
Send campaign emails | Scheduled |
product-map |
Map Shopify products to Sanity | Product sync |
sanity-shopify-product-slug |
Generate product slugs | Product creation |
stale-products |
Identify stale products | Scheduled |
# Deploy a specific function
cd functions/[function-name]
sanity functions deploy
# Deploy all functions
sanity functions deploy --allLocation: sanity-apps/
Custom applications built with the Sanity SDK for specialized workflows.
Purpose: System notification management and monitoring
Features:
- Real-time notification dashboard
- Notification filtering and categorization
- Automated cleanup and archiving
- Webhook integration for external systems
Usage:
cd sanity-apps/notifications
pnpm dev# Shopify Configuration
SHOPIFY_STORE_DOMAIN=your-store.myshopify.com
SHOPIFY_STOREFRONT_ACCESS_TOKEN=your_token
SHOPIFY_STOREFRONT_API_VERSION=2024-01
# Sanity Configuration
SANITY_PROJECT_ID=your_project_id
SANITY_DATASET=production
SANITY_API_TOKEN=your_token
# Algolia (Optional)
ALGOLIA_APP_ID=your_app_id
ALGOLIA_SEARCH_API_KEY=your_keySANITY_PROJECT_ID=your_project_id
SANITY_DATASET=production
SANITY_API_TOKEN=your_tokenSANITY_PROJECT_ID=your_project_id
SANITY_DATASET=production
SANITY_API_TOKEN=your_token
SHOPIFY_STORE_DOMAIN=your-store.myshopify.com
SHOPIFY_ACCESS_TOKEN=your_tokenThe repository uses pnpm workspaces for monorepo management:
{
"workspaces": [
"sanity",
"web"
]
}Deploy to Shopify Oxygen:
cd web
pnpm build
shopify hydrogen deploy
# Or use the Hydrogen CLI directly
npx @shopify/cli hydrogen deployDeploy to Sanity:
cd sanity
pnpm build
sanity deployDeploy all functions:
sanity functions deploy --allDeploy Sanity SDK apps:
cd sanity-apps/[app-name]
pnpm build
sanity deploy- Sanity API: docs.sanity.io
- Shopify Storefront API: shopify.dev
- Hydrogen: hydrogen.shopify.dev
- ESLint: Configured for TypeScript and React
- Prettier: Code formatting
- TypeScript: Strict type checking
# Run type checking
pnpm typecheck
# Run linting
pnpm lint
# Run tests (when available)
pnpm test| Command | Description |
|---|---|
pnpm dev |
Start all services in development |
pnpm build |
Build all workspaces |
pnpm typecheck |
Run TypeScript type checking |
pnpm lint |
Run ESLint |
pnpm clean |
Clean build artifacts |
We use the Sanity Connect for Shopify app
- Product Sync: Automatic product synchronization
- Image Management: Asset upload and optimization
- Inventory: Real-time inventory updates
- Search: Advanced product search
- Filtering: Dynamic filtering capabilities
- Analytics: Search analytics and insights
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
- Follow TypeScript best practices
- Use meaningful commit messages
- Update documentation for new features
- Test changes across all workspaces
This project is licensed under the MIT License - see the LICENSE file for details.
This repo is meant to be an educational reference, this is not meant to be a goto market starter repo for building out custom commerce experiences. If you have questions about implementation strategy feel free to raise questions in our Discord to start a conversation.
This project has been migrated from Remix to React Router v7, following the official migration guide. Key changes include:
- File-based routing: Uses
@react-router/fs-routesfor automatic route generation - Import changes: All routing imports now use
react-routerinstead of@remix-run/react - Hydrogen integration: Uses
@shopify/hydrogen/react-router-presetfor Hydrogen compatibility - Type safety: Full TypeScript support with generated types
- Hydrogen: Updated to 2025.7.0 with latest features
- Sanity: Updated to v4.10.1 with AI Assist and improved performance
- React Router: Migrated to v7.9.2 with file-based routing
- Tailwind CSS: Updated to v4.1.6 with improved performance
Built with โค๏ธ using Sanity, Shopify Hydrogen, and modern web technologies.
