Function: createStorefrontClient()
createStorefrontClient(
config):StorefrontClient
@doswiftly/storefront-sdk — Core (framework-agnostic)
100% framework-agnostic, 0 runtime dependencies. Works in Node.js, Edge Workers, Deno, Bun, CLI scripts — without React.
Parameters
config
Returns
Example
import {
createStorefrontClient,
authMiddleware,
currencyMiddleware,
retryMiddleware,
timeoutMiddleware,
errorMiddleware,
CartClient,
AuthClient,
} from '@doswiftly/storefront-sdk';
const client = createStorefrontClient({
apiUrl: 'https://api.doswiftly.pl',
shopSlug: 'my-shop',
middleware: [
authMiddleware(() => getToken()),
currencyMiddleware(() => getCurrency()),
retryMiddleware({ maxRetries: 2 }),
timeoutMiddleware({ timeout: 5000 }),
errorMiddleware(),
],
});
const cartClient = new CartClient(client);
const cart = await cartClient.create();