The useShop hook provides access to the airsokoConfig prop of the AirsokoReactProvider component.
Usage
import { AirsokoReactProvider, useShop } from "@airsoko/react";
export default function MyApp() {
return (
<AirsokoReactProvider
storeDomain="my-airsoko-store"
storefrontToken="abc123"
storefrontApiVersion="2024-10"
countryIsoCode="KE"
languageIsoCode="EN"
>
<ShopInfo />
</AirsokoReactProvider>
);
}
export function ShopInfo() {
const shopInfo = useShop();
return (
<>
<div>Store Domain: {shopInfo.storeDomain}</div>
<div>Storefront Token: {shopInfo.storefrontToken}</div>
<div>Storefront API Version: {shopInfo.storefrontApiVersion}</div>
</>
);
}Props
| Name | Type | Description |
|---|---|---|
| storeDomain | string | The full domain of your Airsoko storefront URL. |
| storefrontToken | string | The Storefront API public access token. |
| storefrontApiVersion | string | The Storefront API version. |
| countryIsoCode | CountryCode | The code designating a country, following ISO 3166-1 alpha-2 guidelines. |
| languageIsoCode | LanguageCode | ISO 369 language codes supported by Airsoko. |
| getStorefrontApiUrl | (props?: GetStorefrontApiUrlProps) => string | Function to create the fully-qualified URL to your store's GraphQL endpoint. |
| getPublicTokenHeaders | (props: GetPublicTokenHeadersProps) => Record<string, string> | Function to return headers needed for each query to Storefront API GraphQL endpoint using the public token. |
| getAirsokoDomain | (props?: GetAirsokoDomainProps) => string | Function to create the fully-qualified URL to your myAirsoko.com domain. |
| storefrontId | string | The globally-unique identifier for the Shop. |