Notification
Advanced Notification System for RedM
Introduction
cas-notification is a modern NUI-based notification system for RedM.
It uses a React + TypeScript frontend and a lightweight Lua client to display stylish, animated notifications with:
Success, error and info styles
Optional sound effects
Progress bar support
Sticky (no-timeout) notifications
Click-to-dismiss behavior
Alignment and position options
It is framework-agnostic and can be used with any framework or no framework at all.
Features
Clean, RDR2-styled notification design (success, error, info skins)
Configurable alignment (left or right side of the screen)
Top or bottom stacking position
Per-notification options:
Custom title and message
Type: success, error, info
Custom timeout duration
Sticky (no auto-dismiss)
Progress bar display
Click-to-dismiss toggle
Sound enable/disable
Custom sound volume
Meta data (arbitrary Lua table)
Default timeouts per type:
success: 4000–5000 ms
error: 6000–7000 ms
info: 5000–6000 ms
Concurrency limiting: keeps up to 4 notifications on screen at once
Built-in client event for triggering notifications from other resources
Export-based API
Test command that demonstrates multiple notification configurations
Requirements
Any framework (or none)
Installation
Place the resource in your server’s resources folder as:
Add it to your
server.cfg:
There is no server-side Lua logic for this resource; everything is client-side and NUI.
Configuration
Configuration is entirely client-side in the config folder.
Client Config
File: config/client_config.lua
alignDefault horizontal alignment for notifications. Accepts"left"or"right". Each notification can override this per payload.testCommandThe name of the test command registered ifenableTestCommandistrue. Default:/NotificationsenableTestCommandWhentrue, registers the test command that showcases several sample notifications.
The React frontend also reads config.position if present, but by default only align is defined in this config.
You can safely extend the Config table if needed; it is passed to NUI through cas_notify:getLocaleAndConfig.
Icons
Icons are taken from the react-icons Font Awesome 6 set. Browse icons on the React Icons website and use their exact component names (e.g. FaSmoking, FaHammer) as the icon value.
https://react-icons.github.io/react-icons/icons/fa6/
Locale
File: config/locale.lua
LocaleCurrent active language:"en","fr", etc.Locales[...]Strings for notification type labels.
You can add new languages by extending Locales and changing Locale.
Notification Payload Structure
On the frontend side, the notification interface looks like:
On the Lua side, normalizePayload fills defaults:
typedefaults to"info"timeoutdefaults based on type if not specifiedidis auto-generated if not provided
Important fields:
messageThe main text content.type"success","error", or"info".titleShort title displayed at the top of the notification.timeoutDuration in milliseconds before auto-dismiss. If not set, defaults are:success: 4000–5000 ms
error: 6000–7000 ms
info: 5000–6000 ms
stickytruemakes the notification not auto-dismiss (or treatstimeout <= 0as sticky).playSoundIffalse, no sound is played. Default is sound on.soundVolumeFloat between 0 and 1. Default is0.1.progressBarIffalse, hides the small progress bar at the bottom. Default is enabled.allowClickDismissIffalse, disables dismissing the notification by clicking on it. Default is enabled.align"left"or"right". If not present, falls back toConfig.align.position"top"or"bottom". If not present andconfig.position === "bottom", it uses bottom; otherwise top.metaCustom metadata you want to attach (for debugging or tooling).
Lua API
Exports
All API is client-side.
1) addNotification
message(string or table) If a table, it can be the full payload. If a string,notifType,duration, andoptsare used to enrich it.notifType(string, optional)"success","error","info".duration(number, optional) Timeout in milliseconds.opts(table, optional) Extra notification payload fields (title, sticky, align, position, etc.).
Examples:
2) successNotification
A shorthand for notifying with type "success".
3) errorNotification
A shorthand with type "error".
4) infoNotification
A shorthand with type "info".
Client Event
You can also trigger notifications via event instead of exports:
Equivalent to calling exports["cas-notification"]:addNotification(...).
Example:
Test Command
The test command is controlled by Config.enableTestCommand and Config.testCommand.
If enableTestCommand = true, a command is registered:
So by default, you can run:
and see a sequence of different styled notifications.
You can rename this command by changing Config.testCommand.
Usage Examples
Basic success notification
Error notification with title and bottom-right alignment
Info notification without progress bar and click-to-dismiss disabled
Sticky notification (no timeout)
Troubleshooting
Notifications not showing
Make sure the resource is started:
ensure cas-notification
Ensure
web/build/index.htmland assets exist.Check for NUI errors in the F8 console.
Make sure no other NUI resource is blocking or overriding focus.
Wrong alignment or position
Check
Config.aligninclient_config.lua.Ensure payloads do not override
alignandpositionunexpectedly.
Sound not playing
Confirm your client has sound enabled.
Make sure
playSoundis not set tofalsein payload.Check
soundVolumeis not set to0.
Credits
Script name:
cas-notificationAuthor: CAS
Frontend: React + TypeScript + Framer Motion
Assets: Custom success, error, info containers and heat textures
Platforms: RedM
Last updated