getStoreIdentifier
Returns which store the current request or page is for, as sent in the store-identifier header; platform plumbing that themes rarely need.
import { getStoreIdentifier } from '@salla.sa/twilight-theme-engine/utils';In plain words
Every call to the Salla API names the store it is about. getStoreIdentifier() returns that name: a store id, a username or a domain, whichever the request, the address or the server render provided.
It exists for the platform: the API client already sends it with every request. A theme needs it only to label its own requests, caches or logs.
Signature
function getStoreIdentifier(explicit?: string): string // '' when nothing answers
Example
import { getStoreIdentifier } from '@salla.sa/twilight-theme-engine/utils';
/** Prefixes a cache key with the store it belongs to. */
export function storeCacheKey(key: string): string {
return `${getStoreIdentifier() || 'unknown-store'}:${key}`;
}
How it behaves
It only delegates:
getStoreIdentifier(x)returnsresolveStoreIdentifier(x)from@salla.sa/twilight-theme-engine/api/store, whose page lists the order of the answers. The API client sets thestore-identifierheader through this name.On a merchant's own domain the answer is the host. On
localhostandpreview.salla.designit comes from?storeId=, its cookie, or the store username in the first path segment.
Gotchas
The answer's form depends on the host: a numeric id on one, a username such as
dev-vgckq3fssfhjewwior a domain on another. Treat it as an opaque string; never parse it as a number.