useAppContext
useAppContext() là runtime API chính cho mọi hosted native surface. Import từ @sota/platform; hook throw nếu không có app surface provider.
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 | Ý nghĩa |
|---|---|
appId, appVersion | App package hiện tại được chọn cho lane này. |
organizationId, workspaceId | Tenant context đã verify; workspaceId có thể vắng ngoài workspace scope. |
surface | Surface kind hiện tại; dùng cho presentation, không dùng để authorize. |
theme, locale, t | Presentation và localization hiện tại. |
fetch | Cùng scoped data-plane function với useAppFetch. |
lifecycle | Cancellation và cleanup theo mount. |
ui | Host actions cho toast, navigation, artifact và lightbox. |
Các giá trị được server stamp từ resolved execution. Không dựng lại identity organization, workspace, app hoặc environment từ URL hay local storage.