Out now! Check out the Poll results: Do you have a Shopify store?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

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

GkPayments
Shopify Partner
11 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