Guide

ox_lib basics: notifications, menus and progress bars

Learn ox_lib basics for FiveM: install and start it, show notifications, build a simple menu and run a progress bar, with short examples from the official docs.

Short answer: ox_lib is a free library resource that gives your FiveM scripts a shared lib global. Add shared_script '@ox_lib/init.lua' to your resource, make sure ensure ox_lib appears before your resource in server.cfg, and then call lib.notify, lib.registerContext with lib.showContext, or lib.progressBar from your Lua code.

What ox_lib is

ox_lib (by Overextended) is a library resource. Scripts that load it get common helpers for interface work, such as notifications, context menus and progress bars. The official documentation lists each module and its options at overextended.dev/ox_lib.

Installing and starting ox_lib

  1. Download ox_lib from its GitHub releases page and place the folder in your server's resources folder.
  2. In the fxmanifest.lua of your own resource, import the library.
  3. In server.cfg, start ox_lib before any resource that uses it. A resource that loads before ox_lib can fail because the lib global does not exist yet. For more on ordering, see resource start order, ensure lines and dependencies.

Example (fxmanifest.lua of your resource):

shared_scripts {
    '@ox_lib/init.lua',
}

Example (server.cfg):

ensure ox_lib
ensure my_resource

Notifications

lib.notify(data) shows a notification on the client. The official docs say a title or a description is required. The defaults are type = 'inform', position = 'top-right' and duration = 3000. The accepted types are inform, error, success and warning.

Example (client script):

lib.notify({
    title = 'Garage',
    description = 'Your vehicle is ready.',
    type = 'success'
})

To show a notification from the server, trigger the client event: TriggerClientEvent('ox_lib:notify', source, data), where data is the same table.

A context menu has two steps. lib.registerContext(context) registers the menu under an id, and lib.showContext(id) opens it. Each entry in options can use fields such as title, description and onSelect.

Example (client script):

lib.registerContext({
    id = 'example_menu',
    title = 'Example menu',
    options = {
        {
            title = 'Say hello',
            description = 'Shows a notification',
            onSelect = function()
                lib.notify({ description = 'Hello!', type = 'inform' })
            end
        }
    }
})

RegisterCommand('examplemenu', function()
    lib.showContext('example_menu')
end, false)

Progress bars

lib.progressBar(data) displays a running bar. The docs require duration and label. Optional fields include canCancel, useWhileDead and disable. The docs describe the call as asynchronous, and their example treats a finished bar as a truthy result and a cancelled bar as falsy. Two related helpers are lib.progressActive(), which returns true while a bar is running, and lib.cancelProgress(), which cancels a bar that can be cancelled.

Example (client script):

local finished = lib.progressBar({
    duration = 5000,
    label = 'Repairing...',
    useWhileDead = false,
    canCancel = true,
    disable = { move = true, car = true }
})

if finished then
    lib.notify({ description = 'Repair complete', type = 'success' })
end

Common mistakes

  • Starting your resource before ox_lib. Put ensure ox_lib above any resource that imports it.
  • Missing the import line. If lib is nil, check that the shared_scripts line in your fxmanifest.lua is present and that the resource name is spelled ox_lib.
  • Calling lib.notify on the server. It is a client function. Use TriggerClientEvent('ox_lib:notify', source, data) from the server.
  • Leaving out title and description. A notification needs at least one of them.
  • Opening a menu before registering it. Call lib.registerContext first, then lib.showContext with the same id.

FAQ

Can I call lib.notify from the server?

No. lib.notify runs on the client. From the server, trigger the ox_lib:notify client event with TriggerClientEvent.

Why does my menu not open?

Check that lib.registerContext runs before lib.showContext, and that both use the same id string.

Can a player cancel a progress bar?

Only if you set canCancel = true. Your script can check the state with lib.progressActive() and stop it with lib.cancelProgress().

Sources

Last checked: 30 November 2026

Note: The code above is a short example, not a complete script. Check field names against the current official documentation before you use them on a live server.

FiveM.tools was founded with sponsorship from Nyru.