How to access oxygen variables defined in hydrogen.config.ts on client side?

GkPayments
Shopify Partner
9 0 1

 

export default defineConfig({
  shopify: {
    defaultCountryCode: 'IN',
    defaultLanguageCode: 'EN',
    storeDomain: Oxygen.env.PUBLIC_STORE_DOMAIN,
    storefrontToken: Oxygen.env.PUBLIC_STOREFRONT_API_TOKEN,
    privateStorefrontToken: Oxygen.env.PRIVATE_STOREFRONT_API_TOKEN,
    storefrontApiVersion: '2022-07',
    storefrontId: Oxygen.env.PUBLIC_STOREFRONT_ID,
  }
});

How can I access storeDomain and storeFrontToken variables defined in the 'hydrogen.config.ts' file in a component I created in the Hydrogen repo?

 

Reply 1 (1)

leon_snow426
Shopify Partner
1 0 0

Hello @GkPayments 

Did you find the solution?

 

Here is the one for Hydrogen v1.

You can use useHook hooks from @shopfy/hydrogen

  const {storeDomain} = useShop()

 

Refer to this link 

 

Hope this helps
Leon