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.

app/components/AppsDebug.tsx
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

MethodParametersReturnsRequestLogin needed
apps.snippetsnonePromise<AppSnippet[]>GET apps/snippets (timeout 2500 ms)No
apps.settingsnonePromise<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

QueryKeyOptions
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: 0 in the query. It stops the router's default retry from doubling the server wait. Pass your own retry in the browser, as the example does.
  • Empty results. A missing data becomes [] for snippets and { apps: {} } for settings.
  • Errors. HTTPError and TimeoutError propagate from the methods.
  • Guests. No token is required.

See also

On this page