Back to Arky

Quick Start

Initialize Arky once, then use the backend modules your custom website needs.

Get Arky running under a custom website. Start with the storefront SDK helper: it wraps the SDK, manages contact/session context, loads the backend cart, and exposes the modules a frontend or implementation agent needs.

Installation

npm install arky-sdk

Initialize Arky

import { initialize } from 'arky-sdk/storefront';

export const arky = initialize({
  baseUrl: 'https://api.arky.io',
  storeId: 'your-store-id',
  locale: 'en',
  market: 'us',
  marketForLocale: (locale) => (locale === 'it' ? 'ita' : 'us'),
});

Use Modules

const website = await arky.cms.entry.get({
  collection_id: 'pages',
  key: 'website',
  locale: 'en',
});

await arky.action.track({
  key: 'page.view',
  payload: { path: location.pathname },
});

const cart = await arky.eshop.cart.load();

initialize creates the storefront API once. After that, call only the modules the page needs. CMS content is loaded through collection entries, action goes through Action, and carts go through Commerce.

Fetch Products

const { items: products } = await arky.eshop.product.list({
  limit: 20,
});

const product = products[0];
const variant = product.variants[0];

await arky.eshop.cart.addProduct(product, variant, 1);

React To Cart State

const unsubscribe = arky.eshop.cart.snapshot.subscribe((snapshot) => {
  console.log(snapshot.item_count);
  console.log(snapshot.product_items);
});

await arky.eshop.cart.quote();

unsubscribe();

Fetch CMS Content

const website = await arky.cms.entry.get({
  collection_id: "pages",
  key: "website",
  locale: 'en'
});
const hero = website.fields.find((field) => field.key === 'hero');
const title = arky.utils.getBlockTextValue(hero, 'en');

Fetch Services

const { items: services } = await arky.eshop.service.list({
  limit: 50,
});

await arky.eshop.service.initialize();
await arky.eshop.service.select(services[0]);
await arky.eshop.service.findFirstAvailable();
Note

The lower-level client is still available as arky.client, but storefronts should usually use the storefront modules: cms, eshop, crm, action, automation, store, and utils.

Next Steps