The Client SDK is generated specifically for your project using the Frontstack CLI.
Client SDK Hero

Generate Client SDK

Follow this guide to generate the Client SDK for your project

Methods

client.block

Fetch a block by its key.

Parameters

  • name (string): The name of the block to fetch.
    • Example: 'ProductCard'
  • key (string): The key of the block to fetch.
    • Example: '123'
  • config (object, optional): Additional configuration options.
    • requestUrl (string, optional): A URL that will be used to track the origin of the request.
    • contextKey (string, optional): A token that identifies the user’s context state (locale, region).

Returns

  • A promise that resolves to the block response.

Usage

const data = await client.block("ProductCard", "<product-id>", {
  requestUrl: "https://demo-shop.com/snowboards",
  contextToken: "<context-token>",
});

client.listing

Fetch a listing with optional parameters and query options.

Parameters

  • name (string): The name of the block to fetch.
    • Example: 'CategoryListing'
  • params (object, optional): The parameters to pass to the listing.
    • Example: { categoryId: '<category-id>' }
  • config (object, optional): Additional configuration options.
    • query (object, optional): Query parameters to pass to the listing.
      • filter (array): An array of filter objects to filter results.
      • sort (array): An array of sorting options to sort results.
      • search (string): A text search query.
      • limit (number): Limit the number of results returned.
      • page (number): Paginate results.
    • requestUrl (string, optional): A URL that will be used to track the origin of the request.
    • contextKey (string, optional): A token that identifies the user’s context state (locale, region).

Returns

  • A promise that resolves to the listing response.

Usage

const data = await client.listing(
  "CategoryListing",
  { categoryId: "<category-id>" },
  {
    query: {
      filter: { type: "equals", field: "name", value: "Red Dress" },
    },
    requestUrl: "https://demo-shop.com/sunglasses",
    contextToken: "<context-token>",
  }
);

client.page

Fetch a page by its slug.

Parameters

  • slug (string): The URL slug of the page (without protocol).
    • Example: demo-shop.com/uk/women/shoes/running
  • config (object, optional): Configuration options.
    • requestUrl (string, optional): A URL that will be used to track the origin of the request.
    • contextKey (string, optional): A token that identifies the user’s context state (locale, region).

Returns

  • A promise that resolves to the page data.

Usage

const pageData = await client.page('demo-shop.com/uk/women/shoes', {
  requestUrl: 'https://demo-shop.com/uk/women/shoes',
  contextToken: <context-token>
});

client.context

Fetch a context by its token.

Parameters

  • token (string): The token of the context.
    • Example: 'ae0d4981-c363-4d5a-a49e-1f053d49f2f7'

Returns

  • A promise that resolves to the context and token.

client.contextList

Fetch a list of contexts, optionally using a token.

Parameters

  • token (string, optional): The token of the context.
    • Example: 'ae0d4981-c363-4d5a-a49e-1f053d49f2f7'

Returns

  • A promise that resolves to an array of contexts and a context token.

client.contextUpdate

Update a context with new region and locale.

Parameters

  • context (object): The context details to update.
    • region (string): The region to update.
    • locale (string): The locale to update.
  • token (string): The token of the context.

Returns

  • A promise that resolves to the updated context.