Magic Modalv9

Introduction

Build imperative, awaitable, type-safe modal flows in React Native.

React Native Magic Modal turns a modal interaction into a value you can await. Mount one portal near the root of your app, then show a modal from a component, navigation handler, service, or plain function.

const result = await magicModal.show<ConfirmationResult>(() => (
  <ConfirmationModal />
)).promise;

if (
  result.reason === MagicModalHideReason.INTENTIONAL_HIDE &&
  result.data.confirmed
) {
  completePurchase();
}

Why use it?

The mental model

There are only three important pieces:

  1. MagicModalPortal owns the modal stack. Mount it once.
  2. magicModal.show pushes content from anywhere and returns a promise.
  3. useMagicModal closes the current modal with typed data.

Designed for application modals

For a scroll-heavy bottom sheet with snap points, use a dedicated bottom-sheet library. Magic Modal is strongest when a modal represents a discrete interaction or async decision.

Next step

Install the package and its peers, then mount the portal in your app root.

On this page