One-command global notification (toast) setup for React, React Native/Expo, and Next.js
npm install nim-react-toastify> β‘ One-command global toast notification system for React, Next.js, and React Native / Expo.
nim-react-toastify automatically sets up a modern, beautiful notification (toast) system in your project β with a single command.
It detects your stack type (React, Next.js, or React Native), finds your appβs root file, injects a global , and creates a ready-to-use hook.
---
- β
Automatic stack detection (react, react-native, or nextjs)
- π Auto-locates root file (App.tsx, src/App.tsx, app/layout.tsx, app/_layout.tsx, etc.)
- π§ Auto-wires provider & import (no manual setup)
- π¬ Beautiful notification design
- Matches your screenshot style (cyan pill with dark text)
- βοΈ Works with both JSX and TSX
- π§± No external dependencies
- π§΅ Same API for all platforms
---
``bash`
npm i nim-react-toastify
``
npx nim-react-toastify
``
yarn nim-react-toastifyor
pnpm dlx nim-react-toastify
When you run npx nim-react-toastify, the CLI:
1. Detects your stack
If next found β assumes Next.js
If react-native / expo found β assumes React Native / Expo
Else β assumes React (Vite/CRA)
2. Finds your root file
Checks for:
``
app/layout.tsx, app/_layout.tsx, App.tsx, src/App.tsx, index.tsx, etc.
NotificationsProvider
3. Imports the built-in provider
It references the that ships inside nim-react-toastify, so no files are created in your project.
4. Injects import & wrapper
It adds:
``
import { NotificationsProvider } from "nim-react-toastify";
`
and wraps your app with:
`
5. β
Done! Your app now has a global notification context.
After running npx nim-react-toastify, you can immediately use the toast system from anywhere in your app.
NotificationsProvider now exposes preset palettes that you can reference via the preset prop plus an optional theme override object. Available preset names are default, dark, light, cyan, blue, purple, emerald, sunset, charcoal, and coral.
`
import { NotificationsProvider } from "nim-react-toastify";
// quick select
// preset + tweaks (action color still cyan)
theme={{
actionColor: "#38BDF8",
}}
>
...
`
If you need the raw palettes, the package also exports themePresets so you can reuse them manually:
`
import { NotificationsProvider, themePresets } from "nim-react-toastify";
`
`
import { useNotifications } from "nim-react-toastify";
export default function Demo() {
const { show } = useNotifications();
return (
onClick={() =>
show({
type: "success",
message: "Order placed successfully",
actionLabel: "View Order",
onActionPress: () => alert("Navigating to Order..."),
})
}
>
Place Order
);
}
`
`
import React from "react";
import { Button, View } from "react-native";
import { useNotifications } from "nim-react-toastify";
export default function ExampleScreen() {
const { show } = useNotifications();
return (
title="Add to Cart"
onPress={() =>
show({
type: "success",
message: "Product added to cart",
actionLabel: "View Cart",
onActionPress: () => console.log("Navigating to cart..."),
})
}
/>
);
}
`
| Option | Type | Default | Description |
| --------------- | -------------------------------- | ------------ | ---------------------------------------------------------- |
| message | string | required | The text displayed in the toast |type
| | "info" \| "success" \| "error" | "info" | Controls icon & color |actionLabel
| | string | β | Optional small button/link text (e.g. βUndoβ, βView Cartβ) |onActionPress
| | () => void | β | Action executed when button pressed |duration
| | number | 3500 | Duration (ms). Set 0 for persistent |testID
| | string | β | Optional test identifier for E2E/UI tests |
``
const { show, hide, clearAll } = useNotifications();
Each toast is a pill-shaped cyan bubble with:
Left icon (β, β, or i)
Main message text
Optional action link (like βUndoβ)
Dismiss β button on right
Smooth stacking (latest appears on top)
Type Icon Color
info βΉοΈ Cyan background
success β Cyan background
error β Cyan background
Designed to match your provided screenshot style exactly.
After running npx nim-react-toastify, no project files are created β the provider comes from the npm package and only your root file (App.tsx, layout.tsx, etc.) is touched.
- Root: src/App.tsx
``
return (
);
- Root: app/layout.tsx
``
export default function RootLayout({ children }) {
return (
);
}
- Root: App.tsx or app/\_layout.tsx
```
export default function App() {
return (
);
}
Fully ESM (Node 16+)
No dependencies, no bundler config required
Safe idempotent injection (runs multiple times without duplication)
Creates minimal & readable context code
Designed for instant use without manual wiring
| Stack | Works | Auto-detect | JSX/TSX |
| -------------------- | ----- | ----------- | ------- |
| React (Vite, CRA) | β
| β
| β
|
| Next.js (App Router) | β
| β
| β
|
| React Native / Expo | β
| β
| β
|
MIT License
Β© 2025 NimCloud Systems β Developed by ZaYn Miraj.