SDK Initialization
Each platform initializes the SDK with:
- API key
- Environment or base URL
- Optional merchant or application identifier
- Optional analytics hooks
- Optional checkout handlers
- Optional navigation delegate
Shared Initialization Model
All platforms accept a common set of configuration options:
apiKey: string
baseUrl?: string
environment?: "production" | "staging"
appId?: string
merchantId?: string
locale?: string
currency?: string
onEvent?: (event) => void
onNavigateToProduct?: (product) => void
onInstantCheckout?: (payload) => voidPlatform-Specific Initialization
React / TypeScript
Wrap your application tree with ProductAdsProvider:
import { ProductAdsProvider } from "@nohi/product-ads-sdk";
export function AppProviders({ children }: { children: React.ReactNode }) {
return (
<ProductAdsProvider
apiKey={process.env.PRODUCT_ADS_API_KEY!}
environment="production"
appId="web-storefront"
locale="en-US"
currency="USD"
onEvent={(event) => {
console.log("product-ads event", event);
}}
>
{children}
</ProductAdsProvider>
);
}Last updated on