Overview
Platform detection utilities help you identify which host platform (ChatGPT, Claude, etc.) is running your app, so you can conditionally use platform-specific features.Import
detectPlatform
Detect the current host platform.Signature
Platform Type
Detection Order
- Runtime objects — checks for
window.openai(injected by ChatGPT and by the simulator when ChatGPT host is selected) - User agent — checks
navigator.userAgentfor platform identifiers - Hostname — checks
window.location.hostnamefor known host domains
Usage
isChatGPT
Check if the app is running in a ChatGPT host.Signature
Usage
isClaude
Check if the app is running in a Claude host.Signature
Usage
Simulator Behavior
In the Simulator, platform detection reflects the currently selected host:| Host selected | isChatGPT() | isClaude() | detectPlatform() |
|---|---|---|---|
| ChatGPT | true | false | 'chatgpt' |
| Claude | false | false* | 'unknown'* |
useHostContext() to read host identity from the MCP protocol instead.
See Also
ChatGPT Hooks
Platform-specific hooks for ChatGPT features.
useHostContext
Read host identity and capabilities via the MCP protocol.