API Reference
frac exports hooks and utilities from @usefractal/frac/web that work across multiple runtimes. See the compatibility matrix below for platform-specific availability.
State Management
Section titled “State Management”Get initial tool input, output and metadata
Persist state across view renders
Context Sync
Section titled “Context Sync”Sync view UI state with the model for contextual responses
Utilities
Section titled “Utilities”Create a Zustand store that automatically syncs with view state
Generate fully typed hooks from your MCP server
User Interface
Section titled “User Interface”Get layout and visual environment (theme, safe area)
Get user information (locale, device type)
Get and request view display mode changes
Open a modal portaled outside of the view iframe
Resize the view to an arbitrary size
Actions
Section titled “Actions”Call tools from within a view
Open external links
Send a follow-up message in the conversation
Upload and download files
Set URL for “open in app” button in fullscreen mode in ChatGPT
Advanced
Section titled “Advanced”Low-level hook to subscribe to window.openai state values (Apps SDK)
Low-level hook to subscribe to MCP App host context (MCP Apps)
Import
Section titled “Import”All hooks and utilities are exported from @usefractal/frac/web:
import { createStore, useCallTool, useDisplayMode, useFiles, useLayout, useSetOpenInAppUrl, useAppsSdkContext, useMcpAppContext, useOpenExternal, useRequestModal, useRequestSize, useSendFollowUpMessage, useToolInfo, useUser, useViewState,} from "@usefractal/frac/web";Runtime Compatibility
Section titled “Runtime Compatibility”frac supports two runtime environments: Apps SDK (ChatGPT) and MCP Apps (open specification). Most hooks work in both, but some features are platform-specific.
| Hook / Feature | Apps SDK | MCP Apps | Notes |
|---|---|---|---|
| useToolInfo | ✅ | ✅ | |
| useViewState | ✅ | ⚠️ | MCP Apps: polyfilled; state doesn’t persist across view renders |
| data-llm | ✅ | ⚠️ | MCP Apps: polyfilled (same limitation as useViewState) |
| useCallTool | ✅ | ✅ | |
| useSendFollowUpMessage | ✅ | ✅ | |
| useOpenExternal | ✅ | ✅ | |
| useLayout | ✅ | ✅ | |
| useUser | ✅ | ✅ | |
| useDisplayMode | ✅ | ✅ | |
| useFiles | ✅ | ❌ | Apps SDK only |
| useSetOpenInAppUrl | ✅ | ❌ | Apps SDK only |
| useRequestModal | ✅ | ⚠️ | MCP Apps: polyfilled; renders in iframe instead of host modal |
| useRequestSize | ❌ | ✅ | MCP Apps only |
| useAppsSdkContext | ✅ | ❌ | Apps SDK only |
| useMcpAppContext | ❌ | ✅ | MCP Apps only |