Mods & customization Guide

Ox Lib FiveM: installation and Lua context menu example

Set up ox_lib, import its Lua init file, register a small context menu, and separate library startup, UI build and server authorization problems.

Original Magnate concept artwork; not a GTA VI screenshot Original concept artwork · Not game footage

Install the library before resources that import it

Use a release package or follow the documented source web-build workflow. Repository source alone does not establish that the UI is built.

Import @ox_lib/init.lua before scripts using lib, preserve the referenced resource name and declare the dependency. Follow module-specific permission requirements instead of guessing broad grants.

Use a separate staging resource for the example below. This guide reviews the published API and upstream revision 011d670; it does not claim a tested combination of every framework, game edition or fork.

fxmanifest.lua — minimal consumer resource
fx_version 'cerulean'
game 'gta5'

dependency 'ox_lib'
shared_script '@ox_lib/init.lua'
client_script 'client.lua'

Register and open a small Lua context menu

The context API uses lib.registerContext to define a menu and lib.showContext to open it by its unique ID. Register this static menu once, then use the command to show it. The documentation advises against repeatedly registering an unchanged static menu.

Place the following in client.lua and start the staging resource. Run magnate_libmenu in F8, select the item and check the client-console message. Close and reopen the menu. Magnate has not executed this example inside FiveM; it is a documentation-based starting point for your test.

client.lua — local diagnostic menu
lib.registerContext({
    id = 'magnate_library_check',
    title = 'Magnate library check',
    options = {
        {
            title = 'Check local selection',
            description = 'Print a diagnostic message in F8.',
            onSelect = function()
                print('Magnate: context item selected.')
            end
        }
    }
})

RegisterCommand('magnate_libmenu', function()
    lib.showContext('magnate_library_check')
end, false)

A working menu is not a server permission check

This sample only prints a local message. It does not grant an item, money, a job or access to a door. If you replace the action with a server event, validate the requested operation on the server against trusted state and permissions. Hiding or disabling a client menu item is not sufficient authorization.

Cfx’s server-security guidance explains why client-triggered events need server-side checks. Keep a UI acceptance test separate from an authorization test. For a restricted action, verify both an allowed player and a disallowed player under the same conditions, then inspect the resulting server state.

Diagnose the layer that failed

Start with the exact error, resource name, version and the smallest reproduction. If lib is unavailable, inspect the import and script execution order. If the command exists but the menu fails, confirm that the ID being opened matches the registered menu and inspect startup errors. If only a modified package fails, compare it with the baseline release on staging.

Do not use a successful library startup as proof that every resource importing it is compatible. Each consumer can rely on different APIs, data or integrations. Test the inventory, targeting or door interaction that actually matters to your community.

Suggested Ox Lib diagnostic record
LayerRecordWhat success establishes
LibraryPackage revision and startup messagesThe intended resource started
ImportManifest path and script orderThe consumer can use the library
Menu registrationMenu ID and startup errorsThe intended menu definition loaded
SelectionObserved local actionThe selected callback ran
Server actionPermission and resulting stateThe gameplay operation was authorized and applied
RegressionOther affected consumersThe change did not break those tested integrations

Theme settings versus a replacement UI package

The documentation exposes primary color and shade settings through ConVars. For deeper UI edits it describes modifying source and rebuilding, rather than editing de-bundled release assets. Treat a third-party redesign as a separate package with its own version and maintenance requirements.

Before deploying a visual change, compare context menus, dialogs and the other interfaces your resources actually use. Keep a known package for rollback and review the change with both an administrator and an ordinary player. A new appearance alone does not establish API compatibility or improve server performance.

Connect the library to your real resource workflow

Once the local sample works in your environment, keep the import pattern and replace the diagnostic menu with one small intended interaction. Give menu IDs and commands names that will not collide with another resource. Add dynamic data only when the static path is understood.

Use the Ox Target guide for world interactions, Ox Doorlock for doorway setup and the inventory guide for storage integration. Those resources can depend on the same library while requiring different configuration and tests. Record the versions together so that an update can be assessed against the whole setup.

Questions, answered.

Is ox_lib a complete FiveM framework?

No. It provides reusable modules and exports. Your framework and gameplay resources remain separate integrations.

Why is lib unavailable in my Lua script?

Check whether the intended ox_lib resource started, whether your manifest imports @ox_lib/init.lua, and whether that import precedes code using lib. Keep the exact error for diagnosis.

Should I register an unchanged menu every time it opens?

The context-menu documentation advises avoiding repeated registration of static menus. Register the definition, then open its ID.

Sources & editorial notes

Source review: November 7, 2026. Platform announcements can change. This guide separates published facts from Magnate’s original analysis and preparation advice.

  1. Overextended — Ox Lib installation and usage Release/source installation, Lua imports and UI build guidance.
  2. Overextended — Ox Lib Context Menu Context registration, display and static-menu guidance.
  3. Cfx — Secure your events Server-side validation of client-triggered actions.
  4. Cfx — Resource manifest Official manifest metadata and file declarations.

Published by an independent editorial brand. Read our editorial standards.

Find your next move

Search the Magnate guide library.

Browse every guide