Skip to main content

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.
If you are starting a new project, follow the 5-Minute Quickstart first. This page is for checking, editing, or manually creating your .env values.

Essential Environment Variables

Shopify and Hydrogen Variables

  1. 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.
  2. PUBLIC_STORE_DOMAIN: Your Shopify store domain, such as your-store.myshopify.com.
  3. PUBLIC_STOREFRONT_API_TOKEN: Public Storefront API access token used by client-side Storefront API calls. This is not required for the mock.shop demo setup.
  4. PRIVATE_STOREFRONT_API_TOKEN: Private Storefront API access token used for server-side Storefront API calls. Keep this value secret.
  5. PUBLIC_STOREFRONT_ID: The numeric Hydrogen storefront ID.
  6. PUBLIC_CHECKOUT_DOMAIN: Checkout domain, often your original Shopify Online Store domain. Some themes fall back to PUBLIC_STORE_DOMAIN.
  7. PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID: Customer Account API client ID.
  8. SHOP_ID: Numeric Shopify shop ID. Pilot builds the Customer Account client from SHOP_ID and PUBLIC_CUSTOMER_ACCOUNT_API_CLIENT_ID. Leave both empty to run without customer accounts; a non-numeric SHOP_ID also turns accounts off.

Weaverse Variables

  1. WEAVERSE_PROJECT_ID: Unique ID for your Weaverse project. Find it in Weaverse Studio under Project Settings.
  2. 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.
  3. WEAVERSE_HOST: Optional Weaverse service host. Default: https://studio.weaverse.io.
  4. WEAVERSE_PUBLIC_API_BASE: Optional base URL for public page and theme-settings reads. Default: https://api.weaverse.io, or WEAVERSE_HOST when 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

  1. PUBLIC_GOOGLE_GTM_ID: Google Tag Manager ID for analytics.
  2. JUDGEME_PRIVATE_API_TOKEN: API token for Judge.me reviews integration.
  3. KLAVIYO_PRIVATE_API_TOKEN: API token for Klaviyo integration.
  4. PUBLIC_SHOPIFY_INBOX_SHOP_ID: Shopify Inbox shop ID for chat functionality.

Custom Metafields and Metaobjects

  1. METAOBJECT_COLORS_TYPE: Type identifier for color metaobjects.
  2. 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)

Generate a local SESSION_SECRET with either command:

Production Setup

TypeScript Support

For TypeScript support, add your environment variables to env.d.ts. Hydrogen 2026.10 removed HydrogenEnv, so Env extends WeaverseEnv and lists every variable your theme reads:

Best Practices

  1. Security:
    • Never commit .env files to version control
    • Use .env.example for required variables
    • Keep sensitive tokens private
    • Rotate tokens regularly
  2. Organization:
    • Group related variables together
    • Use clear, descriptive names
    • Document all variables in your project
    • Keep development and production variables separate
  3. 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

For stores on a Shopify plan, use Shopify’s Hydrogen sales channel:
  1. Install the Hydrogen sales channel.
  2. Create one Hydrogen storefront project for your store.
  3. From your local storefront folder, run:
  4. Choose the store, storefront, and environment when prompted.
The command pulls environment variables from the linked Hydrogen storefront and writes them into your local .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:
  1. Install the Headless sales channel.
  2. Create or open a storefront in the Headless channel.
  3. Copy the Storefront API values into .env.
  4. Request the Storefront API permissions your theme needs.
During development, enable the Storefront API scopes required by your theme features. Missing scopes often show up later as product, collection, cart, localization, or metaobject data errors.
If you are on the Shopify Starter plan and cannot use the Hydrogen or Headless channel flow, create a custom app to obtain Storefront API access values.
API Token

Weaverse Project ID

  1. Log in to Weaverse Studio
  2. Open your project and go to Project Settings
  3. Copy your Project ID

Using Environment Variables

Access environment variables in your code:

Next Steps

Learn about creating and managing Weaverse Components – the foundational building blocks of your theme.
Last modified on November 24, 2026