Version: 1.65.6
Installation
npm install lynkowQuick Start
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()callsinit()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.globalsandlynkow.blocks. Withcache: 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. RequirespublishableKey. 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 withUNAUTHORIZED. Never cache a cart response: if the client'sfetchOptionsrevalidate, 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. Withcache: true, responses are cached for 5 minutes.CheckoutService: Places an order from the buyer's cart, accessible via
lynkow.checkout. RequirespublishableKey. Placement waits for every cart call invoked before it, then uses the signed-in session, or for a guest the cart tokenlynkow.cartholds. If the buyer or that token changes before the confirmation arrives, the call rejects withUNAUTHORIZED.ConsentService: Shows the site's cookie consent banner and preferences panel, stores the visitor's answer in
localStoragefor 365 days, logs it, and injects the site's third-party scripts for the accepted categories. Available aslynkow.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. Withcache: 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.cookieson the server and in the browser. For the built-in banner, uselynkow.consent.CustomersService: Buyer accounts: two-step signup (
register, thenactivation.confirm), login, profile, bookings and order history, plus theactivation,passwordReset,addressesandmarketingConsentsub-objects. RequirespublishableKey.
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 aslynkow.legal. Withcache: 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; requirespublishableKey. A signed-in buyer reads their orders withlynkow.customers.orders()andlynkow.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. Withcache: 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.
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
bookorbookings.create. RequirespublishableKey. Every booking needsacceptsTerms: true. A product without an online deposit is confirmed at once; with one,bookreturns apendingbooking and a checkout URL, andrefreshPaymentreports the outcome when the buyer returns. A stored customer session is sent with each booking, which then appears incustomers.me(). ThrowsNOT_FOUND(apiCodePRODUCT_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 throwsLynkowErrorSERVICE_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 withlynkow.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: usefetchOptionsfor your framework's cache.TagsService: Reads the flat labels attached to blog articles, available as
lynkow.tags. Withcache: 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. Withcache: true, responses are cached for 5 minutes.