Runtime And SDK
Themes use the Shoppex SDK to load storefront data and drive cart + checkout behavior. There are two common ways to use the SDK in a theme:- CDN (global): load the SDK with a
<script>tag, then usewindow.shoppex - npm: install
@shoppex/sdkand import it
Even if your theme runs on localhost, you can still fetch data from the public API by setting
VITE_API_BASE_URL=https://api.shoppex.io.CDN vs npm
SDK Init
Fetch Storefront Data (Store + Products + Groups)
Resolve Shop By Domain (Custom Domains)
If your theme is running on a custom domain, you can resolve the shop first:Source
Reference implementation:themes/default/src/main.tsxthemes/default/src/hooks/useStore.ts
getStore() vs getStorefront()
| Method | Returns | Use When |
|---|---|---|
getStore() | SDKResponse<Shop> | You only need store metadata (name, logo, settings) |
getStorefront() | SDKResponse<StorefrontData> | You need store + products + groups in one call (most common) |
getStorefront() is the recommended method for initial page load — it fetches everything in a single API call.