@subbly/kit
v0.2.2
Published
Downloads
2,157
Readme
Subbly Kit
Framework-agnostic helpers for building Subbly storefronts — a typed API client wrapper plus the cart, product, bundle, subscription and customer logic that a storefront needs.
Use this package directly if you are not on React. For React, prefer
@subbly/react, which wraps this package in hooks and providers.
Installation
From the package manager of your choice:
npm install @subbly/kit
# or
yarn add @subbly/kitUsage
subblyApi is a shared instance. Initialize it once, as early as possible, with the same
options as @subbly/api-client:
import { subblyApi } from '@subbly/kit/api';
subblyApi.initialize({ apiKey: 'API_KEY' });Then use it anywhere:
import { subblyApi } from '@subbly/kit/api';
const cart = await subblyApi.cart.load(cartToken);Note: You can find your API key on the Storefront API keys page in Subbly Admin.
Calling initialize more than once warns and keeps the first client. Reading
subblyApi.client before initializing throws.
Entry points
Import from a subpath to pull in only what you need — importing @subbly/kit/cart does
not drag in the whole API client.
| Import | Contents |
|---|---|
| @subbly/kit | Everything below, re-exported |
| @subbly/kit/api | Configured Storefront API client |
| @subbly/kit/bundle | Bundle forms, pricing, rulesets and appearance |
| @subbly/kit/cart | Cart reads/writes, buy links, widget bridge |
| @subbly/kit/customer | Address formatting |
| @subbly/kit/product | Product forms, plans, pricing, variants |
| @subbly/kit/subscription | Subscription display, status and surveys |
| @subbly/kit/utils | Shared helpers |
