hydrogen/packages/hydrogen/src/components/LocalizationProvider/README.md
2021-11-09 18:20:09 -08:00

1.5 KiB

The LocalizationProvider component automatically queries the Storefront API's localization field for the isoCode and name of the country and availableCountries and keeps this information in a context.

Any descendents of this provider can use the useCountry and useAvailableCountries hooks. The isoCode of the country can be used in the Storefront API's @inContext directive as the country value.

Component type

The LocalizationProvider component is a server component, which means that it renders on the server. For more information about component types, refer to React Server Components.

Example code

{% codeblock file %}

import {LocalizationProvider} from '@shopify/hydrogen';

export function Component() {
  return <LocalizationProvider>{children}</LocalizationProvider>;
}

{% endcodeblock %}