FumadocsRN Device Geometry

What is Device Geometry?

Pixel-perfect hardware detection for React Native - Access cutouts, corners, and display metrics

React Native Device Geometry

Pixel-perfect access to your device's physical screen characteristics. Go beyond basic dimensions — get precise SVG paths for cutouts, bezier curves for corners, HDR capabilities, color gamut information, and real-time geometry updates.

Perfect for immersive apps, games, video players, and any UI that needs to adapt to hardware features like Dynamic Island, notches, punch-holes, and rounded corners.

Why Device Geometry?

Standard React Native APIs give you screen width and height. Device Geometry gives you the exact shape of your screen — including cutouts, corners, safe areas, and advanced metrics — all through a simple TypeScript API.

Quick Example

Here's how easy it is to detect and work with hardware features:

import { useDeviceGeometry } from 'react-native-device-geometry';

function App() {
  const geometry = useDeviceGeometry();

  if (!geometry) return <Loading />;

  const hasDynamicIsland = geometry.mainDisplay.cutouts.cutouts.some(
    cutout => cutout.shapeType === 'pill'
  );

  return (
    <View style={hasDynamicIsland && { paddingTop: 60 }}>
      <YourContent />
    </View>
  );
}
import { DeviceGeometry } from 'react-native-device-geometry';

// Get complete geometry data
const geometry = await DeviceGeometry.getGeometry();

console.log('Screen:', geometry.mainDisplay.metrics);
console.log('Cutouts:', geometry.mainDisplay.cutouts.cutouts);
console.log('Corners:', geometry.mainDisplay.corners);

// Quick checks
const hasCutout = await DeviceGeometry.hasCutout();
const isFoldable = await DeviceGeometry.isFoldable();
import { DeviceGeometry, EVENTS } from 'react-native-device-geometry';

// Listen for orientation changes
DeviceGeometry.addListener(
  EVENTS.ORIENTATION_CHANGE,
  (event) => {
    console.log('Device rotated!', event);
    updateLayout();
  }
);

// Listen for geometry updates
DeviceGeometry.addListener(
  EVENTS.GEOMETRY_DID_CHANGE,
  async () => {
    const newGeo = await DeviceGeometry.getGeometry();
    refreshUI(newGeo);
  }
);

Key Features


What You Can Build

Immersive Video Players

Draw edge-to-edge while respecting Dynamic Island and notches

Adaptive Game UIs

Adjust HUD elements around cutouts and corners for any device

Multi-Display Apps

Optimize content for external displays and screen mirroring

Foldable Experiences

Create unique layouts that respond to fold angles


How It Works

Device Geometry bridges native iOS and Android APIs to provide a unified, cross-platform interface for accessing hardware geometry data.

iOS (9.0+)

  • Uses UIWindowScene and UIBezierPath to extract cutout shapes
  • Leverages UIScreen for metrics and color gamut
  • Serializes bezier curves into SVG path commands
  • Provides corner radius data from displayCornerRadius

Android (9.0+)

  • Leverages DisplayCutout API for notches and punch-holes
  • Uses RoundedCorner API for corner geometry (Android 12+)
  • Accesses Display for metrics, HDR, and wide color gamut
  • Generates equivalent SVG paths from native shapes

All platform-specific data is normalized into a single TypeScript interface, so you write code once and it works everywhere.


Platform Support

iOS

  • iOS 9.0+
  • Dynamic Island (iPhone 14 Pro+)
  • All notch types (iPhone X+)
  • HDR & P3 color gamut
  • ProMotion (120Hz)

Android

  • Android 9.0+ (API 28+)
  • Punch-hole cameras
  • Teardrop/waterdrop notches
  • Rounded corners (Android 12+)
  • Foldable devices
  • HDR & wide color gamut

For detailed platform compatibility and API level requirements, see the Platform Support page.


Why Choose Device Geometry?

Compared to Standard APIs

FeatureReact Native DimensionsDevice Geometry
Screen width/heightYesYes
Safe area insetsYes (via SafeAreaView)Yes (Recommended to use safe-area-context)
Cutout shapes (SVG paths)NoYes
Corner radius dataNoYes
Bezier curve control pointsNoYes
HDR capabilitiesNoYes
Color gamut (P3, sRGB)NoYes
Refresh rateNoYes
Multi-display supportNoYes
Foldable hinge monitoringNoYes
Real-time geometry eventsNoYes

Performance & Developer Experience

High Performance

Zero runtime overhead with native modules and efficient caching

TypeScript-First

Full type safety, IntelliSense, and predictable API


What You Can Build

Explore detailed guides for common use cases:


Quick Start

Get up and running in minutes:


Ready to build adaptive, hardware-aware UIs? Start with the Quick Start Guide or dive into the API Reference.