@angular/cdk/platform package provides utilities for detecting the current platform, browser, and operating system.
Installation
Platform Service
Detect browser and platform information.Basic Usage
Platform Detection Properties
Environment
Browsers
Operating Systems
Practical Examples
Browser-Specific Features
Mobile Detection
Server-Side Rendering
Touch vs Mouse Input
API Reference
Platform Service
Injectable:{providedIn: 'root'}
| Property | Type | Description |
|---|---|---|
isBrowser | boolean | Whether running in browser |
EDGE | boolean | Microsoft Edge browser |
TRIDENT | boolean | Internet Explorer |
BLINK | boolean | Blink engine (Chrome, Opera) |
WEBKIT | boolean | WebKit engine (Safari) |
FIREFOX | boolean | Firefox browser |
SAFARI | boolean | Safari browser |
IOS | boolean | iOS device |
ANDROID | boolean | Android device |
Helper Functions
getSupportedInputTypes
Check supported input types:supportsPassiveEventListeners
Check for passive event listener support:supportsScrollBehavior
Check for smooth scroll support:Best Practices
- Use for capability detection - Not browser sniffing
- Progressive enhancement - Feature detection over platform detection
- SSR safety - Always check
isBrowserbefore using window/document - Test across platforms - Don’t assume behavior
- Combine with BreakpointObserver - For responsive layouts