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

cdn

objectAdvancedserverbrowser

A bare ky client for Salla's public CDN at cdn.salla.network; it sends no store, language or customer headers.

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

In plain words

Some Salla files are the same for every store and live on a public CDN (a network of servers that hands out files quickly), such as the shared translations. cdn.get('js/translations.json') downloads from https://cdn.salla.network/.

Unlike api, it adds nothing to the request: no store, no language, no token.

Signature

const cdn: KyInstance
// ky.extend({ prefix: 'https://cdn.salla.network', timeout: 5000 })   no hooks, no extra headers

Example

app/dev/translationsSize.ts
import { cdn } from '@salla.sa/twilight-theme-engine/api/client';

/** How large the shared translations file is, for a debug panel. */
export async function translationsSize(): Promise<number> {
  const text = await cdn.get('js/translations.json').text();
  return text.length;
}

How it behaves

  • Its only use inside the engine is translations.get().

  • Errors throw HTTPError like any ky call; translations.get is the one caller that catches them.

Gotchas

  • It is not an image helper and has nothing to do with cdn.assets.salla.network. For theme assets and resized images use useAsset() from the hooks.

Related

Source and docs