Introduction
Environment variables connect your Hydrogen storefront to Shopify, Weaverse Studio, and any third-party services your theme uses. The Weaverse CLI and AI-agent setup generate most local values for you, but it is still useful to know which variables matter and where they come from.Essential Environment Variables
Shopify and Hydrogen Variables
SESSION_SECRET: A random secret used to sign session cookies. The Weaverse CLI/agent setup generates this automatically; if you configure a project manually, generate a random value instead of choosing a memorable one.PUBLIC_STORE_DOMAIN: Your Shopify store domain, such asyour-store.myshopify.com.PUBLIC_STOREFRONT_API_TOKEN: Public Storefront API access token used by client-side Storefront API calls. This is not required for themock.shopdemo setup.PRIVATE_STOREFRONT_API_TOKEN: Private Storefront API access token used for server-side Storefront API calls. Keep this value secret.PUBLIC_STOREFRONT_ID: The numeric Hydrogen storefront ID.PUBLIC_CHECKOUT_DOMAIN: Checkout domain, often your original Shopify Online Store domain. Some themes fall back toPUBLIC_STORE_DOMAIN.PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: Customer Account API client ID.SHOP_ID: Numeric Shopify shop ID. Pilot builds the Customer Account client fromSHOP_IDandPUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID. Leave both empty to run without customer accounts; a non-numericSHOP_IDalso turns accounts off.
Weaverse Variables
WEAVERSE_PROJECT_ID: Unique ID for your Weaverse project. Find it in Weaverse Studio under Project Settings.WEAVERSE_API_KEY: Optional API key from your Weaverse account or project settings. Rendering pages doesn’t need it; only include it when your own code or automation calls the Content API.WEAVERSE_HOST: Optional Weaverse service host. Default:https://studio.weaverse.io.WEAVERSE_PUBLIC_API_BASE: Optional base URL for public page and theme-settings reads. Default:https://api.weaverse.io, orWEAVERSE_HOSTwhen you set a custom host.
WeaverseClient doesn’t read WEAVERSE_API_KEY, so the key never reaches loader data. Before @weaverse/hydrogen 6.5.0, the client copied it into page configs as configs.weaverseApiKey, which was serialized into public loader data. 6.5.0 removed that field from loader data, configs and types; if your code reads configs.weaverseApiKey, delete that use and read WEAVERSE_API_KEY from the environment in server-only code instead.Optional Theme 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 and Metaobjects
METAOBJECT_COLORS_TYPE: Type identifier for color metaobjects.CUSTOM_COLLECTION_BANNER_METAFIELD: Metafield identifier for collection banners.
Variables with
PUBLIC_ can be exposed to browser code. Do not put secrets in PUBLIC_ variables. Keep private API tokens in server-only variables such as PRIVATE_STOREFRONT_API_TOKEN.Setting Up Environment Variables
Using Demo Setup (with mock.shop)
SESSION_SECRET with either command:
Production Setup
TypeScript Support
For TypeScript support, add your environment variables toenv.d.ts. Hydrogen 2026.10 removed HydrogenEnv, so Env extends WeaverseEnv and lists every variable your theme reads:
Best Practices
-
Security:
- Never commit
.envfiles to version control - Use
.env.examplefor 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
Recommended: Hydrogen Sales Channel
For stores on a Shopify plan, use Shopify’s Hydrogen sales channel:- Install the Hydrogen sales channel.
- Create one Hydrogen storefront project for your store.
-
From your local storefront folder, run:
- Choose the store, storefront, and environment when prompted.
.env file. If the CLI cannot pull values yet, copy them manually from Hydrogen sales channel → Storefront settings → Environments and variables.
Alternative: Headless Sales Channel
For development stores, stores without a Shopify plan, or custom Storefront API setups:- Install the Headless sales channel.
- Create or open a storefront in the Headless channel.
- Copy the Storefront API values into
.env. - Request the Storefront API permissions your theme needs.
Weaverse Project ID
- Log in to Weaverse Studio
- Open your project and go to Project Settings
- Copy your Project ID