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.9.1
2,751stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
80/100Excellent
Development Activity80
Maintenance80
Community60
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
86/100Excellent
Architecture85
Code Quality85
Innovation90
Learning Curve85

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 26 apps in this directory

TypeScript
95%
Apache 2.0

AionUi

AI Agents · Productivity

32,102

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
88
Repo Health
76
Technical
66
Dependency
Built with
TypeScript95%
Updated today
Rust
67%
MIT

Bun

Developer Tools

95,452

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
66
Dependency
Built with
Rust67%
C++19%
Updated today
TypeScript
55%
Other

Cap

Team Chat · Video Conferencing

20,986

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
65
Dependency
Built with
TypeScript55%
Rust40%
Updated yesterday
TypeScript
99%
Apache 2.0

Colanode

Knowledge Management · Team Chat · Collaboration

5,018

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
47
Repo Health
73
Technical
73
Dependency
Built with
TypeScript99%
Updated 4 months ago
TypeScript
45%
Other

Convex Backend

Developer Tools · Databases

12,394

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
88
Repo Health
82
Technical
70
Dependency
Built with
TypeScript45%
Rust43%
Updated today
TypeScript
71%
Other

highlight.io

Developer Tools · Analytics · Monitoring

9,367

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
69
Repo Health
78
Technical
66
Dependency
Built with
TypeScript71%
Go16%
Updated yesterday
TypeScript
74%
Apache 2.0

Jitsi Meet

Team Chat · Collaboration · Video Conferencing

29,767

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

View details
96
Repo Health
85
Technical
70
Dependency
Built with
TypeScript74%
JavaScript10%
Updated yesterday
TypeScript
76%
Other

Joplin

Note Taking

56,003

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
62
Dependency
Built with
TypeScript76%
JavaScript15%
Updated yesterday
TypeScript
99%
AGPL 3.0

Karakeep

Bookmarks Archiving

28,454

Self-hosted bookmark manager that captures links, notes, images, and PDFs with AI tagging, full-text search, and automatic archiving.

View details
88
Repo Health
76
Technical
67
Dependency
Built with
TypeScript99%
Updated 3 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

Search