npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

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.

About

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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@omnitoast/native

v0.1.5

Published

Expo / React Native adapter for modal-toast — animated toasts and modal dialogs

Readme

Modal Toast

A universal, headless-first modal and toast notification library for React (Web) and Expo / React Native.

🌐 Live Web Demo (Try it!)

Built with an Adapter Pattern, Modal Toast allows you to write your notification triggering logic once (even outside of React components, like inside Axios interceptors or Redux actions) and guarantees beautiful, fluid presentation across every platform.


📦 Features

  • 🚀 Universal API: Fire toasts using exactly the same code on Web, iOS, and Android.
  • 🧠 Headless Core: Zero-dependency pub/sub state machine ensures the highest performance without tying your logic to any rendering engine.
  • 🎨 Platform Optimized UI:
    • Web: Portal-based rendering, rich CSS glassmorphic theming, and GPU accelerated transforms.
    • Native: Overlay-based unmounted absolute positioning and native Animated APIs for buttery-smooth unblocking performance.
  • ⚙️ Imperative Support: Call toast.success() directly from anywhere. No need to pass down hooks props!

🛠 Installation

Because the business logic is abstracted, you install the core package alongside the adapter for your specific platform.

For React Web

npm install @omnitoast/core @omnitoast/react

Or using pnpm/yarn:

pnpm add @omnitoast/core @omnitoast/react

For Expo / React Native

npm install @omnitoast/core @omnitoast/native react-native-svg react-native-safe-area-context

(Ensure react-native-safe-area-context and react-native-svg are appropriately linked in your app or installed via npx expo install)


💻 Usage: React Web

1. Wrap your App with the Provider

Inject the ToastProvider at the root of your application to host the CSS and Portal.

// App.tsx
import { ToastProvider } from '@omnitoast/react';
import '@omnitoast/react/index.css'; // Don't forget the styles!
import MyComponent from './MyComponent';

export default function App() {
  return (
    <ToastProvider defaultPosition="top-right" maxToasts={5}>
      <MyComponent />
    </ToastProvider>
  );
}

2. Trigger Notifications anywhere

You can either use the standard React Hook configuration, or just import the universal toast manager to trigger state asynchronously without a React cycle.

Option A: Inside a Component (Hooks)

import { useToast } from '@omnitoast/core';

export default function Dashboard() {
  const toast = useToast();

  return (
    <button onClick={() => toast.success('Profile saved successfully!')}>
      Save Profile
    </button>
  );
}

Option B: Outside of React (Imperative)

Perfect for API interceptors or global utilities!

// api.ts
import { toast } from '@omnitoast/core';

api.interceptors.response.use(
  (res) => res,
  (error) => {
    toast.error('Network request failed: ' + error.message);
    return Promise.reject(error);
  }
);

📱 Usage: Expo / React Native

1. Wrap your App with the Provider

Inject the ToastProvider outside of your routing layer. Remember to have your app wrapped in <SafeAreaProvider> from react-native-safe-area-context.

// app/_layout.tsx (Expo Router) OR App.tsx
import { SafeAreaProvider } from 'react-native-safe-area-context';
import { ToastProvider } from '@omnitoast/native';
import { Stack } from 'expo-router';

export default function RootLayout() {
  return (
    <SafeAreaProvider>
      <ToastProvider defaultPosition="top" topOffset={60} maxToasts={4}>
        <Stack />
      </ToastProvider>
    </SafeAreaProvider>
  );
}

2. Triggering Notifications & Modals

Because modal and toast share the exact same headless core engine, they are both accessible directly from the global state. You have two ways to trigger them:

Method A: Destructure from the Hook (Inside React)

import { View, Button } from 'react-native';
import { useToast } from '@omnitoast/core'; // Pull both from useToast!

export default function MobileScreen() {
  const { toast, modal } = useToast();

  const handleDelete = () => {
    modal.danger({
      title: 'Delete Account',
      message: 'This operation cannot be undone. Are you sure?',
      confirmLabel: 'Delete Forever',
      cancelLabel: 'Keep Account',
      onConfirm: () => toast.info('Account fully wiped.')
    });
  };

  return <Button title="Delete Account" onPress={handleDelete} color="red" />;
}

Method B: Direct Global Import (Outside React) Because OmniToast uses an independent state machine, you can launch native modals completely outside of the React lifecycle (e.g. from an API helper without needing hooks).

import { toast, modal } from '@omnitoast/core'; // Imperative globals!

export function handleSystemFailure() {
    modal.danger({
      title: 'Critical Failure',
      message: 'The network connection was lost globally.',
      onConfirm: () => toast.success('Reconnecting...')
    });
}

📖 Component API

ToastProvider

Props vary slightly between platforms because native layout differs significantly from CSS layout.

| Prop | Type | Default | Description | |---|---|---|---| | maxToasts | number | 3 | Max notifications displayed simultaneously before queueing. | | defaultPosition | string | 'bottom-right' (web) / 'top' (native) | Where edge positioning is anchored. | | topOffset | number | 50 | (Native Only) Pixels from the top safe area boundary | | bottomOffset | number| 30 | (Native Only) Pixels from the bottom safe area boundary |

toast.[variant]()

Available Variants: toast.success(), toast.error(), toast.info(), toast.show().

toast.success('Your message here', {
  position: 'top-left', // override default position
  duration: 5000,       // auto-dismiss MS (default 3000)
  id: 'unique-id'       // prevent duplicates
});

modal.[variant]()

Available Variants: modal.info(), modal.danger(), modal.success(), modal.show().

modal.danger({
  title: 'String',
  message: 'String',
  confirmLabel: 'String',
  cancelLabel: 'String',
  onConfirm: () => void | Promise<void>,
  onClose: () => void
});