FiveM ox_lib Tutorial 2026: Setup, Usage and Best Practices

Published on

Complete ox_lib tutorial for FiveM: installation, shared scripts, UI elements, callbacks, zones, progress bars, and integrating ox_lib with QBCore or ESX.

ox_lib is a utility library for FiveM that provides common functions, UI components, and tools used by many modern FiveM resources. It is a dependency for ox_inventory, ox_target, and other ox ecosystem resources.

What ox_lib Provides

  • Context menus and dialog boxes
  • Progress bars and circles
  • Notification system
  • Zone management (sphere, box, poly)
  • Callback system (client-server communication)
  • Shared script loading
  • Input dialogs
  • Skill checks
  • Locale/translation system

Installation

  1. Download ox_lib from its GitHub repository
  2. Place in your server resources folder
  3. Add to server.cfg:
ensure ox_lib

Ensure ox_lib starts before any resources that depend on it.

Using in Your Resources

fxmanifest.lua Setup

fx_version 'cerulean'
game 'gta5'

shared_script '@ox_lib/init.lua'

client_script 'client.lua'
server_script 'server.lua'

The @ox_lib/init.lua shared script initializes the library for both client and server.

Notifications

-- Client-side
lib.notify({
    title = 'Success',
    description = 'Action completed',
    type = 'success'
})

Progress Bar

-- Client-side
if lib.progressBar({
    duration = 5000,
    label = 'Processing...',
    useWhileDead = false,
    canCancel = true,
}) then
    -- Completed
else
    -- Cancelled
end

Context Menu

lib.registerContext({
    id = 'my_menu',
    title = 'My Menu',
    options = {
        {title = 'Option 1', event = 'myResource:option1'},
        {title = 'Option 2', event = 'myResource:option2'},
    }
})

lib.showContext('my_menu')

Callbacks

-- Server-side
lib.callback.register('myResource:getData', function(source)
    return {money = 1000, name = 'Player'}
end)

-- Client-side
local data = lib.callback.await('myResource:getData', false)
print(data.money)

Best Practices

  • Always declare @ox_lib/init.lua as a shared_script
  • Use lib.callback instead of legacy TriggerServerEvent for data requests
  • Use the built-in notification system for consistent UI
  • Check ox_lib documentation for the latest API changes

FAQ

Is ox_lib required for QBCore? Not required, but many modern QBCore resources use ox_lib. It is highly recommended.

Does ox_lib work with ESX? Yes. ox_lib is framework-agnostic.

Does ox_lib affect server performance? Minimal impact. It is a utility library, not a background process.

Related: fxmanifest.lua guide, FiveM resmon guide, pma-voice setup

Launch Your FiveM Server Today

Get started with professional GTA V roleplay hosting powered by enterprise hardware. Instant deployment and 12/7 support included.