Packages
react
hooks
useShop

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

NameTypeDescription
storeDomainstringThe full domain of your Airsoko storefront URL.
storefrontTokenstringThe Storefront API public access token.
storefrontApiVersionstringThe Storefront API version.
countryIsoCodeCountryCodeThe code designating a country, following ISO 3166-1 alpha-2 guidelines.
languageIsoCodeLanguageCodeISO 369 language codes supported by Airsoko.
getStorefrontApiUrl(props?: GetStorefrontApiUrlProps) => stringFunction 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.
storefrontIdstringThe globally-unique identifier for the Shop.