A professional, production-ready toast notification library for React Native.
Featuring a premium floating pill design, glassmorphic backgrounds, smooth spring animations, swipe-to-dismiss gestures, and seamless queue management.
We completely overhauled rn-toastify to feel like a native, premium OS feature rather than a basic third-party library.
- π Ultra-Premium Design: Compact "floating pill" layout with soft, multi-layered drop shadows.
- πͺ Glassmorphism: Semi-transparent backgrounds that beautifully blend with your app's content in both light and dark modes.
- π¨ Edge Accents: Elegant left-edge color indicators for Success, Error, Info, and Warning states.
- π Fluid Physics: Powered by
react-native-reanimatedfor 60fps spring animations and interactive pan gestures. - π¦ Zero Asset Bloat: Completely removed Lottie dependencies. All icons are now built-in, lightweight animated components.
| Feature | Description |
|---|---|
| π¨ 6 Built-in Types | Success, Error, Info, Warning, Loading, Emoji, plus full Custom support. |
| π Interactive Swipes | Swipe horizontally or vertically to intuitively dismiss alerts. |
| π Progress Bar | Animated, flush-to-bottom countdown indicator for auto-dismissal. |
| π System Theme | Automatically adapts to Light/Dark mode, or can be forced via props. |
| π Smart Queue | Set a maxVisible limit; excess toasts automatically queue up. |
| β³ Promise API | Elegant loading β success/error state management for async tasks. |
| β¨οΈ Keyboard Aware | Bottom toasts intelligently shift up when the keyboard appears. |
| π· TypeScript | Built with TS for full type safety and autocompletion. |
npm install rn-toastifyyarn add rn-toastifyThis library relies on the amazing react-native-reanimated for 60fps performance.
npm install react-native-reanimatedNote: Follow the Reanimated installation guide and add the Babel plugin to your
babel.config.js.
For iOS, don't forget to install pods:
cd ios && pod installAdd ToastContainer at the very root of your app structure (e.g., in App.js or your main navigation wrapper).
import React from 'react';
import { NavigationContainer } from '@react-navigation/native';
import { ToastContainer } from 'rn-toastify';
export default function App() {
return (
<>
<NavigationContainer>
<MainNavigator />
</NavigationContainer>
{/* Mount it once at the top level */}
<ToastContainer maxVisible={3} />
</>
);
}Use the useToast hook inside any of your functional components.
import React from 'react';
import { View, TouchableOpacity, Text } from 'react-native';
import useToast from 'rn-toastify';
export default function ProfileScreen() {
const toast = useToast();
const handleSave = () => {
toast.success('Your profile changes have been saved.', {
title: 'Success!',
duration: 3500,
});
};
return (
<View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
<TouchableOpacity onPress={handleSave}>
<Text>Save Profile</Text>
</TouchableOpacity>
</View>
);
}| Method | Returns | Description |
|---|---|---|
success(message, options?) |
string (id) |
Show a green success toast |
error(message, options?) |
string (id) |
Show a red error toast |
info(message, options?) |
string (id) |
Show a blue info toast |
warning(message, options?) |
string (id) |
Show an amber warning toast |
emoji(message, emoji, options?) |
string (id) |
Show a toast with a custom emoji |
custom(content, options?) |
string (id) |
Render entirely custom React nodes |
promise(promise, messages, options?) |
Promise |
Automatically handle async states |
dismiss(id) |
void |
Dismiss a specific toast |
dismissAll() |
void |
Clear the screen of all toasts |
Pass these options as the second argument to customize individual toasts:
| Option | Type | Default | Description |
|---|---|---|---|
title |
string |
undefined |
Bold title text displayed above the message |
duration |
number |
3000 |
Delay in ms before auto-dismissing. Use Infinity to disable. |
position |
'top' | 'bottom' | 'center' |
'top' |
Screen positioning |
Let rn-toastify handle your loading, success, and error states automatically:
const updateProfile = fetch('/api/user', { method: 'PUT', body: data });
toast.promise(updateProfile, {
loading: 'Saving your changes...',
success: 'Changes saved successfully!',
error: 'Failed to save. Please try again.',
});You can pass functions to dynamically render the success/error messages based on the response:
toast.promise(fetchUserData(), {
loading: 'Loading profile...',
success: (user) => `Welcome back, ${user.firstName}!`,
error: (err) => `Error: ${err.message}`,
});Want a toast that never goes away until the user interacts with it?
const id = toast.warning('Please verify your email address.', {
title: 'Action Required',
duration: Infinity,
});
// Dismiss it later via code
toast.dismiss(id);Customize global settings on the <ToastContainer />:
| Prop | Type | Default | Description |
|---|---|---|---|
theme |
'light' | 'dark' |
system | Force a specific theme instead of following OS |
maxVisible |
number |
3 |
Max number of toasts on screen (excess are queued) |
defaultPosition |
'top' | 'bottom' | 'center' |
'top' |
Default positioning for all toasts |
topOffset |
number |
0 |
Extra padding from the top edge |
bottomOffset |
number |
0 |
Extra padding from the bottom edge |
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
This project is MIT licensed.
Crafted with β€οΈ by Mukesh Prajapati
