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

@masumdev/rn-toast

v1.1.4

Published

A simple toast for React Native, inspired by Samsung notifications. This library provides a lightweight toast component with smooth animations and anti-spam protection, ensuring a seamless user experience.

Downloads

40

Readme

@masumdev/rn-toast

A simple toast for React Native, inspired by Samsung notifications. This library provides a lightweight toast component with smooth animations and anti-spam protection, ensuring a seamless user experience.

Sponsor

Demo

Tutorial Video

Demo showing various toast notifications: success, error, and info types with smooth animations and anti-spam protection

Features

  • 🚀 Lightweight and performant
  • 🎨 Customizable styling
  • 🔄 Animation using React Native Reanimated
  • 📱 Works on iOS and Android
  • 📚 TypeScript support
  • 🧠 Smart queueing system for multiple toasts
  • NEW! Custom toast positioning from top

Installation

  1. Make sure you have these peer dependencies installed in your React Native project:

    {
      "react-native-reanimated": "^3.xx",
    }
    npm install react react-native react-native-reanimated
    # or
    yarn add react react-native react-native-reanimated
    # or
    pnpm add react react-native react-native-reanimated
    # or
    bun add react react-native react-native-reanimated
  2. Install the library:

    npm install @masumdev/rn-toast
    # or
    yarn add @masumdev/rn-toast
    # or
    pnpm install @masumdev/rn-toast
    # or
    bun add @masumdev/rn-toast

Usage

Basic Setup

  1. Add the Toaster component to your app's root component:

    import React from 'react';
    import { View } from 'react-native';
    import { Toaster } from '@masumdev/rn-toast';
    
    export default function App() {
      return (
        <View style={{ flex: 1 }}>
          <Toaster />
          {/* Your app content */}
        </View>
      );
    }
  2. Use the useToast hook in your components:

    import React from 'react';
    import { Button, View } from 'react-native';
    import { useToast } from '@masumdev/rn-toast';
    
    export default function MyComponent() {
      const { showToast } = useToast();
    
      const handlePress = () => {
        showToast('Operation successful!', 'success');
      };
    
      return (
        <View>
          <Button title="Show Toast" onPress={handlePress} />
        </View>
      );
    }

Toast Types

The library supports three types of toasts:

  • info (default)
  • success
  • error
// Show an info toast
showToast('This is an info message');

// Show a success toast
showToast('Operation successful!', 'success');

// Show an error toast
showToast('Something went wrong', 'error');

Customization Options

You can customize the duration, animation speed, and position from top:

// Custom duration (8 seconds)
showToast('This will stay longer', 'info', { duration: 8000 });

// Custom animation speed (200ms)
showToast('Quick animation', 'success', { animationDuration: 200 });

// ✨ NEW FEATURE! Custom position from top (120px)
showToast('Custom position', 'info', { position: 120 }); // Customize the distance from top!

Customizing the Toaster Component

You can customize the default behavior of the Toaster component:

import React from 'react';
import { View } from 'react-native';
import { Toaster } from '@masumdev/rn-toast';

export default function App() {
  return (
    <View style={{ flex: 1 }}>
      <Toaster
        defaultDuration={3000} // 3 seconds default duration
        defaultAnimationDuration={300} // 300ms animation
        customIcons={{
          success: require('./assets/my-success-icon.png'),
          error: require('./assets/my-error-icon.png'),
          info: require('./assets/my-info-icon.png')
        }}
        customColors={{
          success: { background: '#e6ffe6', text: '#006600' },
          error: { background: '#ffe6e6', text: '#cc0000' },
          info: { background: '#e6f2ff', text: '#0066cc' }
        }}
      />
      {/* Your app content */}
    </View>
  );
}

Manual Toast Control

You can manually hide toasts using the hideToast function:

import React from 'react';
import { Button, View } from 'react-native';
import { useToast } from '@masumdev/rn-toast';

export default function MyComponent() {
  const { showToast, hideToast } = useToast();

  const showMessage = () => {
    showToast('This is a long toast message...', 'info', { duration: 10000 });
  };

  const hideMessage = () => {
    hideToast(() => {
      console.log('Toast was dismissed');
    });
  };

  return (
    <View>
      <Button title="Show Toast" onPress={showMessage} />
      <Button title="Hide Toast" onPress={hideMessage} />
    </View>
  );
}

API Reference

ToasterProvider Props

| Prop | Type | Default | Description | |------|------|---------|-------------| | position | number | 80 | Position where toasts will appear from top | | duration | number | 3000 | Default duration (in ms) for toasts to remain visible | | offset | number | 16 | Distance from the edge of the screen | | backgroundColor | string | "#333333" | Default background color for toasts | | textColor | string | "#FFFFFF" | Default text color for toasts | | successColor | string | "#4CAF50" | Background color for success toasts | | errorColor | string | "#F44336" | Background color for error toasts | | infoColor | string | "#2196F3" | Background color for info toasts | | warningColor | string | "#FF9800" | Background color for warning toasts | | animationDuration | number | 300 | Duration of show/hide animations | | onToastDismiss | (id: string) => void | - | Callback when a toast is dismissed | | children | ReactNode | - | The content to be wrapped by ToasterProvider |

useToast Hook

The useToast hook provides methods to display and control toasts. Here's a detailed reference of the returned object:

| Method/Property | Type | Description | |----------------|------|-------------| | showToast | (message: string, options?: ToastOptions) => string | Shows a basic toast with default styling | | hideToast | (id: string) => void | Manually hides a specific toast by its ID |

ToastOptions

| Option | Type | Description | |--------|------|-------------| | duration | number | Time in ms the toast should remain visible | | backgroundColor | string | Custom background color for this toast | | textColor | string | Custom text color for this toast |

License

MIT