Skip to content
Twilight React Playground
ثيم رائدaren

STORE_IDENTIFIER_HEADER

constantAdvancedserverbrowser

The name of the store-identifier header, which tells the Salla API which store a request is about.

import { STORE_IDENTIFIER_HEADER } from '@salla.sa/twilight-theme-engine/api/client';

In plain words

The Salla API serves many stores from one address, so each request carries a header naming its store. STORE_IDENTIFIER_HEADER is that header's name, 'store-identifier'.

Set it on a single request to ask about a specific store; the API client then keeps your value instead of adding its own.

Signature

const STORE_IDENTIFIER_HEADER: 'store-identifier'

Example

app/lib/categoriesOf.ts
import { api, STORE_IDENTIFIER_HEADER } from '@salla.sa/twilight-theme-engine/api/client';
import type { Category } from '@salla.sa/twilight-theme-engine/types';

/** Asks about one named store, whichever store the page is rendering. */
export async function categoriesOf(storeId: string): Promise<Category[]> {
  const { data } = await api
    .get('categories', { headers: { [STORE_IDENTIFIER_HEADER]: storeId } })
    .json<{ data: Category[] }>();
  return data ?? [];
}

How it behaves

  • The client sets the header only when the request does not already carry it, so an explicit value is never overwritten.

  • store.settings(id) uses exactly this to send the identifier it checked.

  • The API accepts a store id, a store username or a store domain as the value. It changes that one request only.

Gotchas

  • Only the store header is yours. The language, theme version (s-version-id), token and branch headers still describe the page being rendered, so a question about another store carries this store's theme version and this customer's token.

Related

Source and docs