💎
Headless Docs
Version 0.2.0
Version 0.2.0
  • Overview
  • Change Log
  • Next.js Steps
    • Requirements
    • Determine Page Methods
      • Route Hashing Method
      • Cookies Method
    • Install Middleware
    • Add Intelligems Provider
    • Read User Context
      • Route Hashing Method
      • Cookies Method
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Gatsby Steps
    • Requirements
    • Add Intelligems Provider
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Pack Digital Steps
    • Requirements
    • Add Intelligems Provider
    • Track Page Views
    • Update Prices on Page
    • Update ATC Events
    • Preview Your Site
  • Examples
    • Content Testing
  • Reference
    • Middleware Objects
      • IgMiddlewareConfig
      • IgMiddlewareHandler
    • Providers
      • Next.js
      • Gatsby
    • Components
      • Price Components
    • Hooks
      • Price Hooks
      • Track Hooks
      • Experiment Hooks
      • Test Group Hooks
      • Cart & Checkout Hooks
Powered by GitBook
On this page
  • IntelligemsReactProvider
  • Modifying State Direclty
  1. Reference
  2. Providers

Gatsby

IntelligemsReactProvider

interface IgUserContext {
  id?: string;
  isPreview?: boolean;
  isIntegration?: boolean;
  isPreviewAllTraffic?: boolean;
  originalSlug?: string;
  exps?: Record<string, string>;
  ign?: Record<string, string>;
}

interface IgConfig extends Nullable<IgUserContext> {
  config: PluginConfigType | null; // Internal Type
}

export type ActiveCurrency = string | (() => string);
type PriceFormat = 'dollars' | 'cents';

interface IntelligemsReactProviderProps {
  ig: IgConfig;
  organizationId: string; // required
  activeCurrencyCode?: ActiveCurrency;
  storefrontApiToken: string;
  debug?: boolean;
  priceFormat?: PriceFormat;
  version?: '12' | '13';
  children?: ReactNode;
}

export default function MyApp({ Component, pageProps }: AppProps) {
  return (
      <IntelligemsNextProvider
          storefrontApiToken={process.env.GATSBY_STOREFRONT_ACCESS_TOKEN}
          antiFlicker={true}
          organizationId={process.env.GATSBY_INTELLIGEMS_ORG_ID!}
      >
        ...
      </IntelligemsNextProvider>
  )
}

Modifying State Direclty

The following options are availble to change the Intelligems Context directly:

const igContext = useContext(IntelligemsContext);

interface IntelligemsContextType {
  igId: string | null
  organizationId: string;
  setOrganizationId: Dispatch<SetStateAction<string>>;
  ig: IgConfig | null;
  setIg: Dispatch<SetStateAction<IgConfig | null>>;
  exps: Exps;
  setExps: Dispatch<SetStateAction<Exps>>;
  ign: Ign;
  setIgn: Dispatch<SetStateAction<Ign>>;
  framework: Framework;
  setFramework: Dispatch<SetStateAction<Framework>>;
  activeCurrencyCode: string;
  setActiveCurrencyCode: Dispatch<SetStateAction<string>>;
  storefrontApiToken: string;
  setStorefrontApiToken: Dispatch<SetStateAction<string>>;
  priceFormat: PriceFormat;
  setPriceFormat: Dispatch<SetStateAction<PriceFormat>>;
  priceFormatter?: PriceFormatter;
}

PreviousNext.jsNextComponents