> For the complete Lynkow documentation index in agent-friendly format, see [llms.txt](/llms.txt).

# SDK Reference

**Published**: 2026-11-30
**Category**: SDK Reference

Version: `1.66.0`

## Installation

```bash
npm install lynkow
```

## Quick Start

```typescript
import { createClient } from 'lynkow'

const lynkow = createClient({
  siteId: 'your-site-id'
})

const posts = await lynkow.contents.list()
```

## Available Services

- **AnalyticsService**: Loads the Lynkow analytics tracker in the browser and sends pageviews and
events through it. Available as `lynkow.analytics`; every method is a
no-op on the server. In a browser, `createClient()` calls `init()` for
you, and the tracker records pageviews itself, client-side route changes
included. It follows the site's cookie consent mode: on an `'opt-in'` site
it loads only after the visitor accepts analytics.
- **BlocksService**: Reads global blocks, the reusable pieces shared by every page such as a header, footer or
navigation. Available as `lynkow.globals` and `lynkow.blocks`. With `cache: true`, a single
block is cached for 10 minutes. The site configuration is never cached.
- **BrandingService**: Shows the "Made with Lynkow" badge, accessible via `lynkow.branding`.

In a browser, the client mounts the badge at startup when the site config's
`showBranding` is `true`. Every method is a no-op on the server. The badge
follows the page's light or dark theme, and a failed badge request is
ignored.

- **CartService**: Builds and reads the buyer's cart, accessible via `lynkow.cart`. Requires `publishableKey`.
A guest's first CartService.addLine creates the cart and the service keeps its
token in memory; a signed-in buyer's cart comes from their session. Calls run one at a
time in invocation order, and a call whose buyer or token changes before it completes
rejects with `UNAUTHORIZED`. Never cache a cart response: if the client's `fetchOptions`
revalidate, pass `{ fetchOptions: { cache: 'no-store' } }` on cart calls.
- **CategoriesService**: Reads blog categories as a flat list, a nested tree or a single category with its articles,
available as `lynkow.categories`. With `cache: true`, responses are cached for 5 minutes.
- **CheckoutService**: Places an order from the buyer's cart, accessible via `lynkow.checkout`. Requires
`publishableKey`. Placement waits for every cart call invoked before it, then uses the
signed-in session, or for a guest the cart token `lynkow.cart` holds. If the buyer or
that token changes before the confirmation arrives, the call rejects with `UNAUTHORIZED`.
- **ConsentService**: Shows the site's cookie consent banner and preferences panel, stores the
visitor's answer in `localStorage` for 365 days, logs it, and injects the
site's third-party scripts for the accepted categories. Available as
`lynkow.consent`. In a browser, `createClient()` shows the banner for you
until the visitor answers. UI methods are no-ops on the server.
- **ContentsService**: Reads published blog articles, available as `lynkow.contents`.
Draft, scheduled and archived content is never returned. With `cache: true`,
responses are cached for 5 minutes.
- **CookiesService**: Reads the cookie consent configuration and records consent choices, for a
consent UI you build yourself. Available as `lynkow.cookies` on the server
and in the browser. For the built-in banner, use `lynkow.consent`.
- **CustomersService**: Buyer accounts: two-step signup (`register`, then `activation.confirm`), login, profile,
bookings and order history, plus the `activation`, `passwordReset`, `addresses` and
`marketingConsent` sub-objects. Requires `publishableKey`.

`login` and `activation.confirm` keep the session token in client memory and send it
as a Bearer header on account and booking calls; `logout` clears it. The SDK never
persists it: save it yourself and pass it back with `createClient({ customerToken })`.
Throws `NOT_FOUND` when customer accounts are not enabled on the site.

- **EnhancementsService**: Adds browser behavior to HTML rendered from Lynkow content, accessible via
`lynkow.enhancements`: copy buttons on code blocks, inline script execution,
height sync for embedded Lynkow widgets, and CSS that keeps inline text
alignment. The client starts it in the browser, and it also enhances content
added later. Every method is a no-op on the server.

Restyle code blocks by overriding the `--lynkow-code-*` CSS custom
properties. A `light` class or `data-theme="light"` on `<html>` selects the
light variant.

- **FormsService**: Reads form schemas and submits form data, via `lynkow.forms`.

Fetch a form's schema to render it, then submit the visitor's answers keyed
by field id. Submissions carry the honeypot and timestamp spam fields
automatically.

- **LegalService**: Reads legal documents (privacy policy, terms of service), which are pages tagged `'legal'`.
Available as `lynkow.legal`. With `cache: true`, responses are cached for 5 minutes.
- **MarketsService**: Lists the site's active markets: the groups of countries the merchant sells into, each
with its languages and currency. Accessible via `lynkow.markets`, for a country picker
at checkout or a market switcher.

Requires a publishable key: pass `publishableKey` to `createClient()`, or every call
throws `LynkowError` `UNAUTHORIZED`. With `cache: true`, responses are cached for 5
minutes.

- **MediaHelperService**: Builds resized image URLs on the Lynkow image transformation service,
accessible via `lynkow.media`. It makes no request and works on the server
and in the browser. It accepts original Lynkow media URLs and URLs it already
transformed.
- **OrdersService**: Reads an order from the access token of a guest order link, with no buyer session.
Accessible via `lynkow.orders`; requires `publishableKey`. A signed-in buyer reads
their orders with `lynkow.customers.orders()` and `lynkow.customers.order(id)`.
- **PagesService**: Reads published pages such as "About" or "Contact", available as `lynkow.pages`.
A page holds structured data resolved by the API instead of a rich text body.
With `cache: true`, responses are cached for 5 minutes.
- **PathsService**: Lists the site's public URL paths and resolves a URL path to the page it serves, for
static generation, catch-all routes and redirects. Accessible as `lynkow.paths`.
- **PaymentMethodsService**: Lists the payment methods the site accepts at checkout, each with a hosted logo.
Accessible via `lynkow.paymentMethods`, for a row of logos in a footer or next to the
checkout button.

Requires a publishable key: pass `publishableKey` to `createClient()`, or every call
throws `LynkowError` `UNAUTHORIZED`. With `cache: true`, responses are cached for 5
minutes.

- **PickupPointsService**: Searches the pickup points of a shipping option that delivers to one, for the buyer to
choose at checkout. Accessible via `lynkow.pickupPoints`; store the choice with
`lynkow.cart.update({ pickupPointId })`.

Requires a publishable key: pass `publishableKey` to `createClient()`, or every call
throws `LynkowError` `UNAUTHORIZED`. With `cache: true`, responses are cached for 5
minutes.

- **ProductCategoriesService**: Reads the site's visible product categories, as a tree or one at a time. Accessible
via `lynkow.productCategories`.

Requires a publishable key: pass `publishableKey` to `createClient()`, or every call
throws `LynkowError` `UNAUTHORIZED`. With `cache: true`, responses are cached for 5
minutes.

- **ProductCollectionsService**: Reads the site's product collections. Accessible via `lynkow.productCollections`.

Requires a publishable key: pass `publishableKey` to `createClient()`, or every call
throws `LynkowError` `UNAUTHORIZED`. With `cache: true`, responses are cached for 5
minutes.

- **ProductsService**: Reads the site's published product catalogue. Accessible via `lynkow.products`.

Requires a publishable key: pass `publishableKey` to `createClient()`. Without a valid
one, every call throws `LynkowError` `UNAUTHORIZED` (`apiCode` `STOREFRONT_KEY_REQUIRED`,
`STOREFRONT_KEY_INVALID` or `STOREFRONT_KEY_REVOKED`). With `cache: true`, responses
are cached for 5 minutes.

- **ReservationsService**: Bookable products: availability, selectable resources and offerings, and booking
creation with `book` or `bookings.create`. Requires `publishableKey`. Every booking
needs `acceptsTerms: true`. A product without an online deposit is confirmed at once;
with one, `book` returns a `pending` booking and a checkout URL, and `refreshPayment`
reports the outcome when the buyer returns. A stored customer session is sent with each
booking, which then appears in `customers.me()`. Throws `NOT_FOUND` (`apiCode`
`PRODUCT_NOT_FOUND`) when bookings are not enabled on the site.
- **ReviewsService**: Reads approved customer reviews and submits new ones, via `lynkow.reviews`.

A submission is approved at once when its rating meets the site's
auto-approval threshold, and waits for moderation otherwise. Submissions
carry the honeypot and timestamp spam fields automatically.

- **SearchService**: Full-text search with typo tolerance over the site's published articles and, when the site
opts commerce into search, its products, product categories and product collections.
Accessible as `lynkow.search`. Search must be enabled for the site: otherwise every
method throws `LynkowError` `SERVICE_UNAVAILABLE`.
- **SeoService**: Fetches the site's SEO files as raw text: the XML sitemap, robots.txt, llms.txt,
llms-full.txt and the Markdown version of a page. Serve each from a route handler on your
domain. Accessible as `lynkow.seo`. The SDK never caches these files.
- **ShippingOptionsService**: Lists the shipping options of one market, for the buyer to pick at checkout. Accessible
via `lynkow.shippingOptions`; store the choice with `lynkow.cart.update({ shippingOptionId })`.

Requires a publishable key: pass `publishableKey` to `createClient()`, or every call
throws `LynkowError` `UNAUTHORIZED`. With `cache: true`, responses are cached for 5
minutes.

- **SiteService**: Reads the public site configuration (name, domain, locales, branding, analytics consent mode),
available as `lynkow.site`. The client does not cache it: use `fetchOptions` for your framework's cache.
- **TagsService**: Reads the flat labels attached to blog articles, available as `lynkow.tags`.
With `cache: true`, responses are cached for 5 minutes.
- **VariablesService**: Reads the site's variables, the named values (a phone number, an opening status) defined once
in the admin, available as `lynkow.variables`. Read-only. With `cache: true`,
responses are cached for 5 minutes.