React Native Flash Message

0.4.2 · active · verified Sun Apr 19

react-native-flash-message is a widely used utility module for React Native that enables developers to easily create and display highly customizable flashbars, top notifications, and alerts. It is currently in a stable state with version 0.4.2, actively maintained to ensure compatibility with recent iPhone devices, including robust support for display notches (like iPhone X, XR, XS, and XS Max). The library offers both global and local instantiation patterns for its `FlashMessage` component, allowing flexible integration into various application architectures. Its key differentiators include ease of use, extensive customization options for message types (info, success, warning, danger, default), and critical attention to UI/UX details like safe area handling on modern mobile devices. The project has a consistent, though not strictly scheduled, release cadence, primarily focusing on compatibility and bug fixes.

Common errors

Warnings

Install

Imports

Quickstart

This example demonstrates how to integrate `FlashMessage` globally and trigger messages using `showMessage` with different types and positions.

import React from "react";
import { View, Button, StyleSheet, Text } from "react-native";
import FlashMessage, { showMessage } from "react-native-flash-message";

function App() {
  return (
    <View style={styles.container}>
      <Text style={styles.title}>React Native Flash Message Demo</Text>
      <Button
        title="Show Info Message"
        onPress={() => {
          showMessage({
            message: "Hello from Flash Message!",
            description: "This is an example info message.",
            type: "info",
            duration: 3000,
            icon: "success"
          });
        }}
      />
      <View style={{ height: 20 }} />
      <Button
        title="Show Error Message"
        color="red"
        onPress={() => {
          showMessage({
            message: "Something went wrong!",
            description: "Please check your network connection and try again.",
            type: "danger",
            duration: 5000,
            icon: "danger",
            position: "bottom"
          });
        }}
      />
      {/* GLOBAL FLASH MESSAGE COMPONENT INSTANCE - MUST BE THE LAST COMPONENT */}
      {/* This component acts as the container for all flash messages. */}
      {/* It should be placed at the root level of your app, as the very last child. */}
      <FlashMessage position="top" />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: "center",
    alignItems: "center",
    padding: 20,
    backgroundColor: "#f0f0f0"
  },
  title: {
    fontSize: 22,
    fontWeight: "bold",
    marginBottom: 40,
    textAlign: "center"
  }
});

export default App;

view raw JSON →