Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
R

react-native-portal

> 前端框架
Open source

A simplified portal implementation for ⭕️ React Native & Web ⭕️.

790 stars0 likes0 views
WebsiteGitHub

About

A simplified portal implementation for ⭕️ React Native & Web ⭕️.

React Native Portal

A simplified portal implementation for ⭕️ React Native ⭕️.


Features

  • Multi portals handling.
  • Multi portal hosts handling.
  • Allow override functionality.
  • Compatible with React Native Web.
  • Compatible with Expo, check out the project Expo Snack.
  • Written in TypeScript.

Installation

bash
yarn add @gorhom/portal

Usage

Simple Portal

This is the very simple usage of this library, where you will teleport your content to the PortalProvider layer of the app.

First, you will need to add PortalProvider to your root component - this usually be the App.tsx.

typescript
export const App = () => (
  
  {... your app goes here}
  
);

Last, you wrap the content that you want to teleport with Portal.

typescript
const BasicScreen = () => {
  return (
    { ... }
    
      
        Text to be teleported to the root host
      
    
    { ... }
  );
};

Custom Portal Host

This is when you need to teleport your content to a custom portal host PortalHost at any layer in the app.

First, you will need to add PortalProvider to your root component - this usually be the App.tsx.

typescript
export const App = () => (
  
  {... your app goes here ...}
  
);

Second, you will need to add PortalHost at any layer in your app, with a custom name.

typescript
const CustomView = () => {
  return (
    { ... }
    
    { ... }
  );
};

Last, you wrap the content that you want to teleport with Portal and the custom portal host name.

typescript
const BasicScreen = () => {
  return (
    { ... }
    
      
        Text to be teleported to the CustomView component
      
    
    { ... }
  );
};

React Native Screens integration

In order to get your teleported content on top of all native views, you will need to wrap your content with FullWindowOverlay from react-native-screens.

typescript
import { FullWindowOverlay } from 'react-native-screens';

const BasicScreen = () => {
  return (
    { ... }
    
      
        
          Text to be teleported to the CustomView component
        
      
    
    { ... }
  );
};

React Native Gesture Handler

To avoid issues when using the React Native Portal with React Native Gesture Handler, you must place the PortalProvider under the GestureHandlerRootView, otherwise it might freeze your app.

typescript
export const App = () => (
  
    
    {... your app goes here}
    
  
);

Read more about the app freezing issue.

Props

Portal Props

name

Portal's key or name to be used as an identifer.

required: NO | type: string | default: auto generated unique key

hostName

Host's key or name to teleport the portal content to.

required: NO | type: string | default: 'root'

handleOnMount

Override internal mounting functionality, this is useful if you want to trigger any action before mounting the portal content.

typescript
type handleOnMount = (mount?: () => void) => void;

required: NO | type: function | default: undefined

handleOnUnmount

Override internal un-mounting functionality, this is useful if you want to trigger any action before un-mounting the portal content.

typescript
type handleOnUnmount = (unmount?: () => void) => void;

required: NO | type: function | default: undefined

children

Portal's content.

required: NO | type: ReactNode | ReactNode[] | default: undefined

PortalHost Props

name

Host's key or name to be used as an identifier.

required: YES | type: string

Hooks

usePortal

To access internal functionalities of all portals.

…

Built With ❤️

  • @react-native-community/bob

Author

  • Mo Gorhom

Sponsor & Support

To keep this library maintained and up-to-date please consider sponsoring it on GitHub. Or if you are looking for a private support or help in customizing the experience, then reach out to me on Twitter @gorhom.

License

MIT


Issues· 33 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

TypeScriptportalreactreact-native

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架