npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details


  • User packages



Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.


Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner




A flexible way to handle safe area, also works on Android and web.





npm Supports Android, iOS, web, macOS and Windows MIT License

JavaScript tests iOS build Android build

A flexible way to handle safe area, also works on Android and Web!

Getting started

npm install react-native-safe-area-context

You then need to link the native parts of the library for the platforms you are using.

  • iOS Platform:

    $ npx pod-install

Supported react-native version

| version | react-native version | | ------- | -------------------- | | 4.0.0+ | 0.64.0+ |


This library has 2 important concepts, if you are familiar with React Context this is very similar.


The SafeAreaProvider component is a View from where insets provided by Consumers are relative to. This means that if this view overlaps with any system elements (status bar, notches, etc.) these values will be provided to descendent consumers. Usually you will have one provider at the top of your app.


Consumers are components and hooks that allow using inset values provided by the nearest parent Provider. Values are always relative to a provider and not to these components.

  • SafeAreaView is the preferred way to consume insets. This is a regular View with insets applied as extra padding or margin. It offers better performance by applying insets natively and avoids flickers that can happen with the other JS based consumers.

  • useSafeAreaInsets offers more flexibility, but can cause some layout flicker in certain cases. Use this if you need more control over how insets are applied.



You should add SafeAreaProvider in your app root component. You may need to add it in other places like the root of modals and routes when using react-native-screens.

Note that providers should not be inside a View that is animated with Animated or inside a ScrollView since it can cause very frequent updates.


import { SafeAreaProvider } from 'react-native-safe-area-context';

function App() {
  return <SafeAreaProvider>...</SafeAreaProvider>;


Accepts all View props. Has a default style of {flex: 1}.


Optional, defaults to null.

Can be used to provide the initial value for frame and insets, this allows rendering immediatly. See optimization for more information on how to use this prop.


SafeAreaView is a regular View component with the safe area insets applied as padding or margin.

Padding or margin styles are added to the insets, for example style={{paddingTop: 10}} on a SafeAreaView that has insets of 20 will result in a top padding of 30.


import { SafeAreaView } from 'react-native-safe-area-context';

function SomeComponent() {
  return (
    <SafeAreaView style={{ flex: 1, backgroundColor: 'red' }}>
      <View style={{ flex: 1, backgroundColor: 'blue' }} />


Accepts all View props.


Optional, array of top, right, bottom, and left. Defaults to all.

Sets the edges to apply the safe area insets to.

For example if you don't want insets to apply to the top edge because the view does not touch the top of the screen you can use:

<SafeAreaView edges={['right', 'bottom', 'left']} />

Optional, padding (default) or margin.

Apply the safe area to either the padding or the margin.

This can be useful for example to create a safe area aware separator component:

<SafeAreaView mode="margin" style={{ height: 1, backgroundColor: '#eee' }} />


Returns the safe area insets of the nearest provider. This allows manipulating the inset values from JavaScript. Note that insets are not updated synchronously so it might cause a slight delay for example when rotating the screen.

Object with { top: number, right: number, bottom: number, left: number }.

import { useSafeAreaInsets } from 'react-native-safe-area-context';

function HookComponent() {
  const insets = useSafeAreaInsets();

  return <View style={{ paddingBottom: Math.max(insets.bottom, 16) }} />;


Returns the frame of the nearest provider. This can be used as an alternative to the Dimensions module.

Object with { x: number, y: number, width: number, height: number }


React Context with the value of the safe area insets.

Can be used with class components:

import { SafeAreaInsetsContext } from 'react-native-safe-area-context';

class ClassComponent extends React.Component {
  render() {
    return (
        {(insets) => <View style={{ paddingTop: }} />}


Higher order component that provides safe area insets as the insets prop.

type Props = WithSafeAreaInsetsProps & {
  someProp: number;

class ClassComponent extends React.Component<Props> {
  render() {
    return <View style={{ paddingTop: }} />;

const ClassComponentWithInsets = withSafeAreaInsets(ClassComponent);

<ClassComponentWithInsets someProp={1} />;


React Context with the value of the safe area frame.


Insets and frame of the window on initial render. This can be used with the initialMetrics from SafeAreaProvider. See optimization for more information.

Object with:

  frame: { x: number, y: number, width: number, height: number },
  insets: { top: number, left: number, right: number, bottom: number },

NOTE: This value can be null or out of date as it is computed when the native module is created.

Deprecated apis


Use useSafeAreaInsets instead.


Use SafeAreaInsetsContext.Consumer instead.


Use SafeAreaInsetsContext instead.


Use initialWindowMetrics instead.


If you are doing server side rendering on the web you can use initialMetrics to inject insets and frame value based on the device the user has, or simply pass zero values. Since insets measurement is async it will break rendering your page content otherwise.


If you can, use SafeAreaView. It's implemented natively so when rotating the device, there is no delay from the asynchronous bridge.

To speed up the initial render, you can import initialWindowMetrics from this package and set as the initialMetrics prop on the provider as described in Web SSR. You cannot do this if your provider remounts, or you are using react-native-navigation.

import {
} from 'react-native-safe-area-context';

function App() {
  return (
    <SafeAreaProvider initialMetrics={initialWindowMetrics}>


This library includes a built in mock for Jest. It will use the following metrics by default:

  frame: {
    width: 320,
    height: 640,
    x: 0,
    y: 0,
  insets: {
    left: 0,
    right: 0,
    bottom: 0,
    top: 0,

To use it, add the following code to the jest setup file:

import mockSafeAreaContext from 'react-native-safe-area-context/jest/mock';

jest.mock('react-native-safe-area-context', () => mockSafeAreaContext);

To have more control over the test values it is also possible to pass initialMetrics to SafeAreaProvider to provide mock data for frame and insets.

export function TestSafeAreaProvider({ children }) {
  return (
        frame: { x: 0, y: 0, width: 0, height: 0 },
        insets: { top: 0, left: 0, right: 0, bottom: 0 },


See the Contributing Guide