Arky Docs
Implementation docs for using Arky as the backend under custom websites.
Arky is a backend for a custom website. The frontend can be Astro, Svelte, React, Vue, plain TypeScript, or an agent-generated storefront. Arky provides the Admin, the records, the storefront APIs, the SDK helpers, and the modules behind the website.
Keep the website custom. Put repeat backend work in Arky: Content, commerce, bookings, forms, customers, actions, store email, newsletters, support, Admin, API, and SDK.
The Storefront Contract
import { initialize } from "arky-sdk/storefront";
import { createOrderToken } from "arky-sdk/utils";
export const arky = initialize("arky_pk_...", {
locale: "en",
market: "eu",
createVisitorIdentity: () => ({
customer_id: crypto.randomUUID(),
session_id: crypto.randomUUID(),
}),
createSessionId: () => crypto.randomUUID(),
createId: () => crypto.randomUUID(),
createOrderToken,
});
arky.pageViews.send({ path: location.pathname, referrer: document.referrer });
const { items: packages } = await arky.eshop.package.find();
const shopPackage = packages.find((candidate) => candidate.key === "public");
if (!shopPackage) throw new Error("This buyer can't shop here");
const cart = arky.eshop.cart({ buyer: { type: "customer" }, package_id: shopPackage.id });
await cart.load();
After initialize, use only the modules the website needs. A content site might use content,
forms, actions and pageViews. A storefront adds eshop.cart, products, promotions and checkout. A service
business adds bookings through the cart. A newsletter is a free package people join.
Three rules hold everywhere:
- The app picks every id. Creates carry a UUID v4 from your
createId, or one you pass. The SDK keeps a pending id until its answer and sends the same request again under it, so a retry never makes a duplicate. - Changes carry what they read. Updates and actions send the
expected_updated_atthey read; a stale one is refused. Stock actions and two conversation actions name the value they read instead, and a package’s access row, which has no version, is deleted by its id alone. - Language and market are explicit, and the key decides the channel. The storefront sends its language, and its market on every commercial call; its publishable key belongs to one sales channel. Every product read and cart names its package. Arky never falls back to a default.
Build Order
Build on a free test store, and go live on a second store set up by the same script.
- Call
initializeonce when the page or app starts. - Read editable copy from Content collections and entries.
- Add commerce or bookings when the flow needs products, carts, availability, quotes or checkout.
- Track important moments with action keys such as
lead.submittedorcheckout.started, and count page views withpageViews.send. - Create the webhook at Arky’s address in the store’s own Resend account and connect the account with its signing secret, verify its domain there, add a sending address and select a complete email for each purpose the store sends, so receipts, sign-in codes and the other emails go out from the store’s own address.
- Add a chat flow, support email on the store’s receiving domain, and a newsletter when the client needs them.
Core Modules
| Module | Use it for |
|---|---|
| Content | Collections, entries, blocks, media and localization |
| Commerce | Products, variants, carts, promotions, orders, payments, checkout |
| Packages | Shops, price lists, memberships, renewals, club prices and newsletters: one set of things to buy, get or rent |
| Bookings | Booking services, resources, offerings, availability, booking lines |
| Forms | Lead capture, intake, quote requests, applications |
| Customers | Visitor and signed-in customers, sign-in codes, email changes |
| Actions | First-party facts for timelines and experiment goals |
| Page views | Page views, pages, countries, referrers and unique visitors, counted from a beacon that stores nothing |
| The store’s own Resend accounts, sending and receiving addresses, templates with layouts, a complete email per purpose, broadcasts | |
| Support | Fixed-step chat flows, team replies, support email on the store’s own domain |
| API & SDK | Framework-agnostic storefront and Admin access |
Common Starting Points
Content website
const website = await arky.content.load({ collection: { key: "website" } });
const post = await arky.content.load({ entry: { collection_id: blogId, slug: "launch" } });
Product storefront
const { items: [shopPackage] } = await arky.eshop.package.find();
const { items: products } = await arky.eshop.packageItem.find({
package_id: shopPackage.id,
include_price: true,
selection: { types: ["product"] },
limit: 20,
});
await arky.eshop.cart({ buyer: { type: "customer" }, package_id: shopPackage.id }).ensure();
Service booking
const { items: [service] } = await arky.eshop.packageItem.find({
package_id: shopPackage.id,
selection: { types: ["booking_service"] },
});
const calendar = arky.eshop.bookingCalendar({ buyer: { type: "customer" }, package_id: shopPackage.id });
if (service?.item.type === "booking_service")
await calendar.select({ booking_service_id: service.item.booking_service_id });
calendar.selectFirstAvailableDate();
Support chat
const chat = await arky.support.conversation.start({ language: "en", flow_key: "default" });
Next
- Quick Start for the minimal setup.
- Core Concepts for the rules every record follows.
- Store Email for the store’s Resend account, sending addresses and a complete email for each purpose.
- E-commerce Store for products, carts, quotes and checkout.
- Packages for what a store sells, to whom and at what price.
- Support for chat flows and support email.