# apps (https://docs.salla.dev/twilight/react/api/modules/apps)



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.

```tsx title="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 [#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 [#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 [#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 [#see-also]

* [store](https://docs.salla.dev/twilight/react/api/modules/store)
* [Errors, timeouts and retries](https://docs.salla.dev/twilight/react/api/errors-timeouts-and-retries)
