Usage
Function Signature
Parameters
Hook configuration.
If
true, detect OS in an effect for SSR safety; otherwise detect during initial render. Defaults to true.Return Value
Detected operating system. Possible values:
'undetermined'- OS could not be detected or code is running on server'macos'- macOS'ios'- iOS (iPhone/iPad/iPod)'windows'- Windows'android'- Android'linux'- Linux'chromeos'- Chrome OS
Examples
OS-Specific Instructions
Platform-Specific Download
Conditional Feature Display
OS Badge Display
Copy Command with OS Detection
Multi-Platform Support Message
SSR-Safe Detection
Analytics Tracking
Detection Logic
- iOS: Detected by
iPhone,iPad, oriPodin user agent, or macOS with touch support - macOS: Detected by
Macintosh,MacIntel,MacPPC, orMac68Kpatterns - Windows: Detected by
Win32,Win64,Windows, orWinCEpatterns - Android: Detected by
Androidin user agent - Chrome OS: Detected by
CrOSin user agent - Linux: Detected by
Linuxin user agent (excluding Android and Chrome OS)
Notes
- Detection is based on user agent string parsing
- User agents can be spoofed or modified by browser extensions
- Returns
'undetermined'on the server or when detection fails - For SSR safety, use
getValueInEffect: true(default) - Useful for platform-specific UI, instructions, and download links