
Generate Client SDK
Run
frontic generate to produce the typed client for your project - see the CLI reference for the full command.Initialization
The generated client supports two initialization patterns.The Nuxt module needs a client generated with a current CLI. If it warns at build time that your client is outdated, run
frontic generate again.Direct import
For the simplest case - no proxy, no global config:Factory with configuration
For projects that need a global proxy URL (e.g. browser-side requests routed through your own server to avoid CORS):Server-side with a secret
If your project’s Fetch API is protected by a secret, pass it to server-side clients. The client sends it asfs-secret on every request:
server/frontic.ts
Configuration
createClient(config?)
Create a configured client instance.
Parameters
Returns
Methods
Every method below shares the sameconfig object as a final argument, used to override per-request behaviour. The shared options are listed once here and referenced from each method.
Shared config object
Every method takes an optional config object as its final argument. Not every field applies to every method - the table below in each method’s section calls out which ones are honoured.
client.block
Fetch a Detail Block by its key.
Parameters
See shared
config object.Returns
Example
Client SDK
client.listing
Fetch a Search Listing with optional parameters and query options.
Parameters
Listing parameters. Shape depends on the listing’s parameter definition.
Example:
{ categoryId: '<category-id>' }.Returns
The listing payload - items, pagination metadata, applied filters, available facets.
Example
Client SDK
client.tree
Fetch a Menu Tree - a hierarchical collection of records assembled from a Data Storage and rendered through a Detail Block.
Parameters
Tree-specific query options plus the shared
config object.Returns
An
items array of root-level nodes, each carrying its subtree on $items. Every node’s shape (beyond $items) is defined by the tree’s connected Detail Block.Example
Client SDK
client.page
Fetch a Page by its slug.
Parameters
The URL slug of the page (without protocol). Example:
demo-shop.com/uk/women/shoes/running.See shared
config object.Returns
Example
Client SDK
client.sitemap
Fetch a Sitemap. The Nuxt module can serve the sitemap route from your app automatically.
Parameters
The shared
config object.Returns
string
The XML content of the sitemap.
Example
Client SDK
client.context
Fetch a context by its token.
Parameters
See shared
config object.Returns
Example
Client SDK
client.contextList
List the available contexts (region + currency + locales) for the project, optionally filtered by an existing context token.
Parameters
See shared
config object.Returns
Example
Client SDK
client.contextUpdate
Update an existing context’s region and locale on the Frontic server. Subsequent requests using the same contextKey reflect the change.
Parameters
See shared
config object.Returns
Example
Client SDK
Response
Response
Types
Framework types - pages, context, filters, sorting, pagination - live under theFrontic namespace in the generated types, so they never collide with a Data Type of the same name. Your own response types, such as ProductCard, are global.
Error handling
A method rejects when the Fetch API answers with an error status, or when the request fails or times out before a response arrives. The generated client exportsFronticFetchError, the type of what it rejects with:
catch variable as unknown, so assert the type as shown, or pass it as the error type to a data-fetching library.
The response body is on error.data, typed from your project’s spec as the error bodies the Fetch API returns: ApiError for a deliberate failure and InternalError for a server fault. code is the discriminant - it is present exactly when the failure was deliberate, so narrowing on it gives you the right shape. Branch on code, never on error, whose wording is not stable.
Read the body rather than checking instanceof: only data survives server-side rendering, and the error class is not guaranteed to match across bundles. A failure without a response, such as a timeout, carries no data.
Using the Nuxt module? It narrows the body for you - see Error handling.