react-native-safe-area-context

A flexible way to handle safe area insets in React Native, with hooks and components that also work on Android and web.

Library
npm
v5.10.0
2,760 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
78 /100 Good
Development Activity 72
Maintenance 80
Community 60
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
86 /100 Excellent
Architecture 85
Code Quality 85
Innovation 90
Learning Curve 85

react-native-safe-area-context is the de-facto standard for reading device safe area insets in React Native apps. It exposes a SafeAreaProvider, a SafeAreaView component, and hooks like useSafeAreaInsets that give you the exact top, bottom, left, and right padding needed to keep your UI clear of notches, status bars, home indicators, and rounded corners.

Unlike the older platform-specific approaches, it works consistently across iOS, Android, web, macOS, and Windows, and supports the New Architecture (Fabric). Because insets are delivered as plain numbers through React context, you can drive layout, animations, and scroll offsets from them with full control instead of relying on an opaque wrapper component.

What You Get

  • A SafeAreaProvider that measures the device’s safe area and shares insets and frame through React context.
  • useSafeAreaInsets and useSafeAreaFrame hooks that return precise numeric insets and window dimensions.
  • A SafeAreaView component with configurable edges and padding/margin modes for declarative safe layouts.
  • Cross-platform native implementations for iOS, Android, web, macOS, and Windows, including New Architecture (Fabric) support.
  • initialMetrics and a SafeAreaListener for synchronous first render and imperative inset change handling.

Common Use Cases

  • Padding a screen’s header and footer so they clear the notch and home indicator on modern phones.
  • Positioning floating buttons or toolbars a fixed distance above the bottom safe area.
  • Building custom tab bars and navigation headers that adapt to each device’s insets.
  • Driving animated values or scroll offsets from the exact inset numbers instead of hardcoded constants.

Under The Hood

Architecture The library splits a thin JavaScript layer from platform-native measurement code. src/SafeAreaContext.tsx defines two React contexts (SafeAreaInsetsContext and SafeAreaFrameContext) and the SafeAreaProvider, which wraps a NativeSafeAreaProvider and listens for an onInsetsChange event to update inset and frame state, memoizing to avoid re-renders when values are unchanged. Platform is resolved through file extensions (NativeSafeAreaProvider.web.tsx, .windows.tsx, .native.ts variants of InitialWindow), and the native side is generated via Fabric codegen (codegenConfig in package.json, specs under src/specs) with implementations in Objective-C/Objective-C++ (ios/), Kotlin/Java (android/), and shared C++ (common/). Consumer hooks read straight from context and throw a descriptive error when no provider is mounted.

Tech Stack Written in TypeScript (strict tsconfig), built with react-native-builder-bob into CommonJS, ES module, and typings outputs. It declares react and react-native as peer dependencies with zero runtime dependencies of its own. Native code targets the New Architecture through React Native codegen; the repo uses Jest with @testing-library/react-native, ESLint, Prettier, clang-format, and Spotless for multi-language formatting.

Code Quality The codebase is small, well-typed, and tested: src/__tests__ contains Jest suites for the context, the view, and initial-window metrics, including snapshot tests. Error handling is explicit (a clear NO_INSETS_ERROR thrown from the hooks), state updates are guarded against redundant renders, and deprecated APIs (useSafeArea, SafeAreaConsumer) are retained with @deprecated markers for backwards compatibility rather than removed abruptly.

API Design The public surface is deliberately minimal and ergonomic. useSafeAreaInsets() returns a plain { top, right, bottom, left } object, SafeAreaView offers declarative edges and mode props, and a withSafeAreaInsets HOC covers class components. Naming is consistent and discoverable, the single index.tsx re-exports everything, and setup requires only wrapping the app in one provider — a low-boilerplate, well-documented developer experience backed by a dedicated docs site.

Used by 28 apps in this directory

Go
59%
Apache 2.0

agent-orchestrator

AI Agents · AI Code Assistants · Developer Tools

12,440

A local desktop workspace that gives every coding task its own agent, Git branch, and worktree, then tracks tasks, pull requests, CI, and reviews for 27 coding agents on one live Kanban board.

View details
86
Repo Health
83
Technical
68
Dependency
Built with
Go 59%
TypeScript 38%
Updated 4 days ago
TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

33,179

Free, open-source Cowork desktop app that unifies Claude Code, Codex, Gemini CLI, and 20+ AI agents into a single platform with multi-agent teams, 24/7 cron automation, and zero-config built-in agent.

View details
85
Repo Health
76
Technical
66
Dependency
Built with
TypeScript 95%
Updated 3 weeks ago
Rust
67%
MIT

Bun

Developer Tools

96,068

An all-in-one JavaScript and TypeScript toolkit — one Rust-and-JavaScriptCore binary that replaces Node.js, npm, a bundler, and a test runner with faster equivalents.

View details
92
Repo Health
91
Technical
64
Dependency
Built with
Rust 67%
C++ 19%
TypeScript 10%
Updated 5 days ago
Rust
54%
Other

Cap

Team Chat · Video Conferencing

22,884

Open source Loom alternative with GPU-accelerated recording, instant share links, AI summaries, and full self-hosting via Docker Compose.

View details
89
Repo Health
81
Technical
64
Dependency
Built with
Rust 54%
TypeScript 42%
Updated 4 days ago
TypeScript
99%
Apache 2.0

Colanode

Collaboration · Knowledge Management · Team Chat

5,152

Local-first, self-hosted workspace that combines real-time chat, Notion-style pages, and structured databases — all synced via CRDTs so you work offline without losing a keystroke.

View details
46
Repo Health
73
Technical
70
Dependency
Built with
TypeScript 99%
Updated 6 months ago
TypeScript
45%
Other

Convex Backend

Databases · Developer Tools

12,617

Open-source reactive database that lets developers build live-updating apps with pure TypeScript, strong consistency, and real-time subscriptions—no separate API layer required.

View details
87
Repo Health
82
Technical
68
Dependency
Built with
TypeScript 45%
Rust 43%
Updated 6 days ago
TypeScript
71%
Other

highlight.io

Analytics · Developer Tools · Monitoring

9,378

Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.

View details
67
Repo Health
78
Technical
65
Dependency
Built with
TypeScript 71%
Go 16%
Updated 1 months ago
TypeScript
74%
Apache 2.0

Jitsi Meet

Collaboration · Team Chat · Video Conferencing

30,004

Open-source, end-to-end encrypted video conferencing you can self-host or embed into any web or mobile app.

View details
95
Repo Health
85
Technical
66
Dependency
Built with
TypeScript 74%
JavaScript 10%
Updated 6 days ago
TypeScript
77%
Other

Joplin

Note Taking

56,513

The privacy-first, open-source note-taking app with end-to-end encrypted sync, AI assistance, and a powerful plugin ecosystem across every platform.

View details
93
Repo Health
87
Technical
60
Dependency
Built with
TypeScript 77%
JavaScript 14%
Updated 5 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers