Documentation Index
Fetch the complete documentation index at: https://mintlify.com/pieroenrico/tune-me-in/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Thesanity.config.js file contains the core configuration for connecting your Shopify Hydrogen storefront to Sanity CMS. This configuration is used throughout the application to fetch content, build image URLs, and interact with your Sanity project.
Configuration File
Location:sanity.config.js (project root)
Configuration Options
Your Sanity project ID. This uniquely identifies your Sanity project and is required for all API requests.Example:
'wfr1r0dw'How to find: Available in your Sanity project settings at sanity.io/manageThe Sanity dataset to use. Datasets allow you to have multiple content environments (e.g., production, staging, development).Example:
'production'Default datasets: 'production', 'staging', 'development'The Sanity API version to use. This ensures consistent API behavior and allows you to opt-in to new features.Example:
'v2021-06-07'Format: Date string in YYYY-MM-DD format prefixed with vRecommendation: Use the date when you first set up your project or when you want to lock in specific API behaviorWhether to use Sanity’s Content Delivery Network (CDN) for faster content delivery.When to use
true:- Production environments
- Read-heavy applications
- When you want faster response times
- Content can be up to a few seconds behind
false:- Development environments where you need real-time updates
- When you need guaranteed fresh content
- For authenticated requests or draft content
Usage in Application
The Sanity configuration is imported and used throughout the application:Image URL Generation
Insrc/utils/sanityImageUrl.js:
Component Integration
The configuration is imported in various components for image processing:src/components/blocks/BlockImage.client.jsxsrc/components/ProductGallery.client.jsxsrc/components/GalleryCarousel.client.jsxsrc/components/CollectionCard.client.jsx
Shopify Config Integration
The Sanity config is also embedded in the Shopify configuration:Environment-Specific Configuration
For different environments, you can create separate configuration files:Best Practices
Use CDN in Production
Use CDN in Production
Always set
useCdn: true in production for better performance. The CDN provides:- Faster response times
- Reduced load on your origin server
- Global edge caching
Lock API Version
Lock API Version
Use a specific API version rather than
'latest' to ensure consistent behavior across deployments. Update the version intentionally when you want to adopt new features.Separate Datasets
Separate Datasets
Use different datasets for different environments:
productionfor live contentstagingfor pre-production testingdevelopmentfor local development
Version Control
Version Control
Commit your
sanity.config.js file to version control, but ensure sensitive tokens are stored in environment variables if needed.Related Configuration
- shopify.config.js - Shopify configuration that includes Sanity config
Troubleshooting
Images Not Loading
Images Not Loading
Verify that your
projectId and dataset are correct. Image URLs are built using these values and incorrect configuration will result in 404 errors.Stale Content in Development
Stale Content in Development
If you’re seeing outdated content while developing, set
useCdn: false to bypass the CDN cache and get real-time updates.API Version Errors
API Version Errors
If you receive API version errors, check the Sanity API versioning documentation for the correct format and available versions.