---
title: "useAppContext"
description: "useAppContext() is the primary runtime API for every hosted native surface. Import it from @sota/platform; it throws when no app surface provider is mounted."
url: "https://sotaagents.ai/manual/developer-guide/use-app-context"
generated_by: "sotaagents-ldp"
docs_index: "https://sotaagents.ai/manual/llms.txt"
locale: "en"
---

# useAppContext

`useAppContext()` is the primary runtime API for every hosted native surface. Import it from `@sota/platform`; it throws when no app surface provider is mounted.

TSX

```
import { useAppContext } from '@sota/platform';

export function RuntimeDetails() {
  const context = useAppContext();
  return (
    <dl>
      <dt>App</dt><dd>{context.appId}@{context.appVersion}</dd>
      <dt>Organization</dt><dd>{context.organizationId}</dd>
      <dt>Workspace</dt><dd>{context.workspaceId ?? 'none'}</dd>
      <dt>Surface</dt><dd>{context.surface}</dd>
    </dl>
  );
}
```

| Field | Meaning |
| --- | --- |
| `appId`, `appVersion` | The current app package selected for this lane. |
| `organizationId`, `workspaceId` | Verified tenant context. `workspaceId` may be absent outside workspace scope. |
| `surface` | The current surface kind; use it for presentation differences, not authorization. |
| `theme`, `locale`, `t` | Current host presentation and localization. |
| `fetch` | The same scoped data-plane function returned by `useAppFetch`. |
| `lifecycle` | Mount-owned cancellation and cleanup primitives. |
| `ui` | Host UI actions such as toast, navigation, artifact, and lightbox. |

Values are stamped from the server-resolved execution. Never reconstruct organization, workspace, app, or environment identity from URLs or local storage.
