apps
Reads the snippets (scripts and HTML) and per-app settings of the apps installed on the store.
Use apps to read what installed apps want injected into the page. The engine already prefetches both calls, renders the apps' script tags and installs the Salla.appScope settings, so a theme rarely calls this itself.
import { useQuery } from '@tanstack/react-query';
import { apps } from '@salla.sa/twilight-theme-engine/api/apps';
export function AppsDebug() {
const { data: settings, isSuccess } = useQuery({ ...apps.queries.settings(), retry: 2 });
return <pre>{isSuccess ? JSON.stringify(settings, null, 2) : 'Loading'}</pre>;
}Methods
| Method | Parameters | Returns | Request | Login needed |
|---|---|---|---|---|
apps.snippets | none | Promise<AppSnippet[]> | GET apps/snippets (timeout 2500 ms) | No |
apps.settings | none | Promise<AppSettings> | GET apps/snippets/settings (timeout 2500 ms) | No |
An AppSnippet has service, app_id, id?, app_slug, status and snippets: AppSnippetRow[] (place, content, url?, id?, customer_parameters?). AppSettings is { apps: Record<string, Record<string, unknown>> }, keyed by the encoded app id (the same value as AppSnippet.id).
Queries
| Query | Key | Options |
|---|---|---|
apps.queries.snippets() | ['apps', 'snippets'] | staleTime: Infinity, retry: 0 |
apps.queries.settings() | ['apps', 'settings'] | staleTime: Infinity, retry: 0 |
Neither key includes the locale or the scope. The data is treated as fixed for the page load, so there is nothing to refetch.
Gotchas
- Short timeout on purpose. Both calls are awaited while the server renders, so each gets 2500 ms instead of 8000 ms. A slow answer means no tags, never a stalled page.
retry: 0in the query. It stops the router's default retry from doubling the server wait. Pass your ownretryin the browser, as the example does.- Empty results. A missing
databecomes[]for snippets and{ apps: {} }for settings. - Errors.
HTTPErrorandTimeoutErrorpropagate from the methods. - Guests. No token is required.