Standalone and Development Modes
Your app should work in three modes:
| Mode | When | Token Source | Octostar APIs |
|---|---|---|---|
| Production | Running inside Octostar iframe | ContextAPI.getContext() | Fully available |
| Development | Local dev with Octostar backend | OS_JWT env var + OS_DEV_MODE=true | Available via SDK |
| Standalone | Local dev without Octostar | OS_STANDALONE=true | Unavailable — use fallbacks |
Iframe Detection
Disable React StrictMode inside iframes to prevent PostRobot connection issues:
// main.tsx
const isInIframe = (() => {
try { return window.self !== window.top; }
catch { return true; }
})();
const AppWrapper = isInIframe
? App
: () => <StrictMode><App /></StrictMode>;
Conditional Octostar Features
Always check for API availability before using Octostar-specific features:
const { DesktopAPI } = useOctostarContext();
// Octostar environment
if (DesktopAPI) {
const workspaces = await DesktopAPI.getOpenWorkspaces();
}
// Standalone fallback
else {
const workspaces = await api.getWorkspaces();
}
On the backend, wrap SDK imports in try/except:
try:
import octostar.client
OCTOSTAR_SDK_AVAILABLE = True
except ImportError:
OCTOSTAR_SDK_AVAILABLE = False