The PlatformContext
Everything your module knows about the platform arrives through one object: PlatformContext. The shell injects it; you consume it through React hooks.
The shape
interface PlatformContext {
user: PlatformUser; // who's signed in + their roles
building: PlatformBuilding; // the active building
api: PlatformApiClient; // pre-authenticated, tenant-scoped HTTP client
events: EventBusClient; // publish / subscribe to platform events
}Hooks
import {
usePlatformContext,
useBuilding,
useCurrentUser,
useOptionalBuilding,
} from '@tv/extension-sdk/react';
function MyComponent() {
const ctx = usePlatformContext(); // the whole context
const building = useBuilding(); // throws if no building selected
const user = useCurrentUser(); // the signed-in user
const maybe = useOptionalBuilding(); // null instead of throwing
}The api client
ctx.api is an HTTP client that's already carrying the user's auth and scoped to the active tenant. You never see a token.
const spaces = await ctx.api.get(`/api/v1/buildings/${building.id}/spaces`);
await ctx.api.post(`/api/v1/buildings/${building.id}/work-orders`, dto);Why this matters: the same component works in your sandbox and in a customer's production tenant, because the only thing that changes between them — the auth + base URL — is supplied by the platform, not your code.
Don't reach around it
The contract is: PlatformContext is your only door. If you find yourself reading localStorage, building Keycloak URLs, or hardcoding https://tv-api..., stop — that path won't survive moving between tenants, and it's outside what the platform supports.
→ Next: Events