Skip to content

Notifications ​

Toasts appear in the top-right stack, up to Config.MaxToasts; when the stack is full, the oldest is dismissed. The announce variant goes top-centre, one at a time.

Notification variants

Client ​

lua
-- Short form → toast id
local id = exports.np_hud:Notify('Saved', 'Your outfit was saved.', 'success', 3000)

-- Full form
exports.np_hud:Notify({
  title = 'Fuel low', message = 'Your **Sultan RS** is at 12%.', type = 'warning',
  icon = 'gas-pump', tint = 'orange', duration = 6000, sound = true,
  meta = { { icon = 'location-dot', label = 'Alta St' } },
})

-- Same id → updates the toast in place and restarts its timer
exports.np_hud:Notify({ id = id, title = 'Saved', message = 'Updated in place.' })

exports.np_hud:DismissNotify(id)
exports.np_hud:ClearNotify()

From the server, without the export: TriggerClientEvent('np_hud:client:notify', src, data).

Server ​

lua
exports.np_hud:Notify(source, { title = 'Paycheck', message = 'You received **$450**.', type = 'success', icon = 'money-bill' })
exports.np_hud:NotifyAll({ title = 'Weather', message = 'A storm is coming.', icon = 'cloud-bolt' })
exports.np_hud:Announce({ title = 'Server restart', message = 'Restart in **15 minutes**.', tint = 'red' })

Fields ​

FieldTypeNotes
idstring ≤ 64Generated if missing. Reusing an id updates the toast
typeinfo · success · warning · errorDefault info. Framework names are mapped: primary/inform/police/ambulance → info, warn → warning, danger/fail → error
variantdefault · compact · announce · staff · call
appstring ≤ 32Small app label
titlestring ≤ 96Either title or message is required
messagestring ≤ 512Supports **bold** only (no HTML). description and text are accepted as aliases
iconFont Awesome nameWithout prefix: 'gas-pump'
tintneutral red orange rust pink olive lilac green blue aqua brandIcon tile colour
badge0–999
durationms, 0–120000Default 5000. 0 = sticky
progress0–100Shows a static bar instead of the timer. Sticky unless duration is set; closes 600 ms after reaching 100
meta{ icon, label }[] (max 4)Small info chips
actions{ id, label, key?, style? }[] (max 3)style: default · primary · success
soundbooleanPlays a short, quiet blip in the NUI

All payloads are whitelisted and clamped on the way in, so other resources can't push arbitrary data into the NUI.

Actions ​

Actionable toasts can be answered with a click or a key: Y / N by default (Config.NotifyKeys, rebindable as hudaccept / huddecline). A key press goes to the newest actionable toast.

Client-side actions ​

lua
exports.np_hud:Notify({ variant = 'call', title = 'Incoming call', message = 'Mum', duration = 0,
  actions = {
    { id = 'decline', label = 'Decline', key = 'N' },
    { id = 'accept', label = 'Accept', key = 'Y', style = 'success' },
  } })

AddEventHandler('np_hud:notifyAction', function(id, action) print(id, action) end)

Server-side actions ​

lua
exports.np_hud:Notify(src, {
  variant = 'call', title = 'Tow request', message = 'Accept the job?', duration = 0,
  actions = { { id = 'no', label = 'Decline', key = 'N' }, { id = 'yes', label = 'Accept', key = 'Y', style = 'success' } },
}, function(player, action, id)
  if action == 'yes' then --[[ ... ]] end
end)

-- or listen globally (server-local event, fired only after validation):
AddEventHandler('np_hud:notifyAction', function(player, id, action) end)

The server validates every action before it fires the callback or event. The toast must exist, the player must be one of its recipients, the action must be one of the toast's actions, and each player gets one action per toast. NotifyAll accepts the same optional callback.

DANGER

Never use AddEventHandler('np_hud:server:notifyAction', …) in other resources. It's the raw client net event, and nothing has validated it yet.

Framework notifications ​

See Integration → Framework notifications for redirecting QBCore.Functions.Notify, ESX.ShowNotification and lib.notify to np_hud.

np_* FiveM resources