React Native Toast Message

2.3.3 · active · verified Sun Apr 19

React Native Toast Message is a lightweight (~40 kB) and highly customizable animated toast message component designed for React Native applications. It provides an imperative API for easily displaying various types of notifications, including success, error, and info toasts. The current stable version is 2.3.3, with a consistent release cadence focusing on bug fixes, performance improvements, and compatibility updates, as seen with recent fixes for React 19. Key differentiators include its built-in keyboard-aware logic, flexible configuration options, and the ability to define custom toast layouts. The library offers comprehensive documentation for advanced scenarios like integrating toasts within Modals or navigation libraries, which are common pain points in React Native development. It ships with full TypeScript support, ensuring type safety and improved developer experience.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates rendering the `Toast` component at the root of your application and using the imperative `Toast.show()` method to display success and error messages.

import React from 'react';
import { Button, View, StyleSheet, SafeAreaView } from 'react-native';
import Toast from 'react-native-toast-message';

const App = () => {
  const showSuccessToast = () => {
    Toast.show({
      type: 'success',
      text1: 'Success!',
      text2: 'Your operation was completed successfully.',
      visibilityTime: 3000,
      autoHide: true,
      topOffset: 30
    });
  };

  const showErrorToast = () => {
    Toast.show({
      type: 'error',
      text1: 'Error!',
      text2: 'Failed to perform operation. Please try again.',
      visibilityTime: 4000,
      autoHide: true
    });
  };

  return (
    <SafeAreaView style={styles.safeArea}>
      <View style={styles.container}>
        <Button title="Show Success Toast" onPress={showSuccessToast} />
        <View style={styles.spacer} />
        <Button title="Show Error Toast" onPress={showErrorToast} />
        <Toast />
      </View>
    </SafeAreaView>
  );
};

const styles = StyleSheet.create({
  safeArea: {
    flex: 1,
  },
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#F5FCFF',
  },
  spacer: {
    height: 20,
  },
});

export default App;

view raw JSON →