Introduction
Environment variables provide a mechanism to protect sensitive data, manage configurations, and streamline different environments like development, testing, and production. In Weaverse Hydrogen, you’ll frequently interact with a set of predefined variables tailored specifically for the framework.Essential Environment Variables
Core Variables
SESSION_SECRET
: A secret key used to sign session cookies. For more details, refer to the Remix documentation on using sessions.PUBLIC_STOREFRONT_API_TOKEN
: The public access token for the Storefront API. This is not required if you are using themock.shop
demo setup.PUBLIC_STORE_DOMAIN
: The domain of the store used to communicate with the Storefront API.PUBLIC_CHECKOUT_DOMAIN
: The domain of the checkout page (or the original Online Store domain).PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID
: The public access token for the Customer Account API.PUBLIC_CUSTOMER_ACCOUNT_API_URL
: The API URL for the Customer Account API, format:https://shopify.com/{SHOP_ID}
.SHOP_ID
: Your Shopify store ID.
Weaverse Specific Variables
WEAVERSE_PROJECT_ID
: A unique ID representing your specific Weaverse project. You can find this ID inside the Weaverse Studio under Project Settings.WEAVERSE_API_KEY
(optional): Weaverse API Key retrieved from your Weaverse Account settings.WEAVERSE_HOST
(optional): The host URL for Weaverse services. Default:https://studio.weaverse.io
.
Optional Variables
PUBLIC_STOREFRONT_ID
: The ID of your storefront.PRIVATE_STOREFRONT_API_TOKEN
: The private access token for the Storefront API.PUBLIC_STOREFRONT_API_VERSION
: The Storefront API version. Defaults to the version used by Hydrogen.
Third-Party Integration Variables
PUBLIC_GOOGLE_GTM_ID
: Google Tag Manager ID for analytics.JUDGEME_PRIVATE_API_TOKEN
: API token for Judge.me reviews integration.KLAVIYO_PRIVATE_API_TOKEN
: API token for Klaviyo integration.PUBLIC_SHOPIFY_INBOX_SHOP_ID
: Shopify Inbox shop ID for chat functionality.
Custom Metafields & Metaobjects
METAOBJECT_COLORS_TYPE
: Type identifier for color metaobjects.CUSTOM_COLLECTION_BANNER_METAFIELD
: Metafield identifier for collection banners.
Setting Up Environment Variables
Using Demo Setup (with mock.shop
)
Production Setup
TypeScript Support
For TypeScript support, add your environment variables toenv.d.ts
:
Best Practices
-
Security:
- Never commit
.env
files to version control - Use
.env.example
for required variables - Keep sensitive tokens private
- Rotate tokens regularly
- Never commit
-
Organization:
- Group related variables together
- Use clear, descriptive names
- Document all variables in your project
- Keep development and production variables separate
-
Development:
- Use different values for development and production
- Validate environment variables at startup
- Provide fallback values where appropriate
- Use TypeScript for type safety
Obtaining Required Tokens
Storefront API Token
- Install the Headless or Hydrogen app
- Follow these instructions to obtain the Storefront API Token
- When setting permissions, enable all Storefront API access scopes to avoid unexpected errors during development
💡 Tip: Always enable all Storefront API permissions when generating your token. This prevents access-related errors that can be difficult to troubleshoot during development.

Weaverse Project ID
- Log in to Weaverse Studio
- Navigate to Project Settings
- Copy your Project ID