ox_lib for FiveM: what it is, common mistakes and the AI skill
Updated
Don’t want to manage skills yourself? Get the full app.
ox_lib is a standalone FiveM library that provides notifications, dialogs, callbacks, commands, zones and shared helpers for your resources. It works with both ESX and QBCore, and this guide covers setup, common mistakes and the AI skill that uses its real API.
ox_lib is a standalone library for FiveM that gives your resources ready-made UI, client-server callbacks, commands, zones and shared helpers. Resources like ox_inventory and ox_target depend on it, and most modern ESX and QBCore servers already run it. If you write scripts for a server that has ox_lib installed, you should use it instead of building your own NUI or copying legacy menu code.
What ox_lib gives you
Setup is one line in fxmanifest.lua: shared_scripts { '@ox_lib/init.lua' }. You can add ox_libs { 'locale', 'callback' } to preload modules you use often.
- Interface.
lib.notifyfor notifications,lib.alertDialogfor confirmations,lib.inputDialogfor forms, plus context menus, progress bars and TextUI. Icons come from Font Awesome 6. - Callbacks.
lib.callback.registeron the server,lib.callback.awaiton the client. The client asks, the server answers, and you get the value back on the same line. - Commands.
lib.addCommandon the server withhelp,paramsandrestricted, so the command validates its arguments and checks permissions for you. - Zones.
lib.zones.poly,lib.zones.boxandlib.zones.spherewithonEnter,onExitandinsidehandlers. Use them on the client. The server side has limited support. - Utilities. Keybinds, locales,
lib.table,lib.stringand other shared modules.
The full reference is at coxdocs.dev/ox_lib.
Common mistakes with ox_lib
- Forgetting
@ox_lib/init.luain the manifest. The script loads and then dies with "attempt to index a nil value (global 'lib')". Addshared_scripts { '@ox_lib/init.lua' }and make sure ox_lib starts before your resource. - Registering the callback on the wrong side. A client that calls
lib.callback.await('myjob:getData')gets nothing back because the callback was registered on the client too. Register withlib.callback.registeron the server, await on the client. If the server needs to ask a client, pass the player source as the second argument. - Using a callback for fire-and-forget. If the client only needs to tell the server "I pressed the button", a net event is enough. Callbacks block until a response arrives, so use them only when you need a value back.
- Treating zones as a server feature. Zones run on the client, where the player position lives. Server-side zone support is limited, so do enter and exit detection on the client and send the result to the server if you need it.
- Mixing in legacy patterns.
exports.ox_libcalls, old ESX menus and custom NUI for a simple confirm dialog are all signs of code written before ox_lib existed. Replace them withlib.alertDialog,lib.inputDialogand context menus.
Why AI assistants get ox_lib wrong
A generic assistant has seen years of FiveM code, most of it written before ox_lib existed or with an older version of it. Ask for a confirmation dialog and it may invent an export like exports.ox_lib:showDialog, write an ESX menu, or hand you a callback registered on the client. The code looks plausible, then fails on the first run.
The ox_lib skill fixes that with rule files, one per module: init.md, callback.md, interface.md, addCommand.md and zones.md. Each one states the real function names, which side of the network they belong to, and the arguments they take. The assistant reads the rule that matches your request and writes against the documented API instead of guessing.
Install the ox_lib skill in 30 seconds
- Click "Download SKILL.md" at the top of this page.
- Unzip it into the skills or rules folder of your AI tool. The install section below shows the exact path for Claude Code, Cursor and VS Code.
- Ask the assistant for something concrete, like "add a server callback that returns the player's job and show it with lib.notify", and check that it uses
lib.callback.registeron the server andlib.callback.awaiton the client.
How to install this skill
Download the zip, unzip it, and place the folder where your tool loads skills or rules. The exact path depends on the tool:
Claude Code
Unzip into .claude/skills/oxlib/ inside the project (the folder must contain SKILL.md). For every project, use ~/.claude/skills/oxlib/ instead.
Cursor
Cursor loads project rules from .cursor/rules/. Add a rule file there that points to the unzipped skill, or paste the contents of SKILL.md and the rule files into a rule. The format is .mdc with frontmatter and changes between versions, so check the docs for your version.
VS Code / Copilot
Copilot reads instruction files from .github/instructions/*.instructions.md. Copy SKILL.md there with an applyTo glob for your Lua files, and keep the rule files next to it.
The SKILL.md file
This is the file your AI assistant reads. It links to the rule files bundled in the download.
Ox Lib
Standalone library for FiveM: reusable UI, callbacks, commands, and shared modules. Used by many Ox resources (ox_inventory, ox_target, etc.). Always prefer ox_lib over custom NUI or legacy patterns when the user wants notifications, dialogs, menus, or client-server calls.
When to use
- User asks for notifications, alert dialogs, input dialogs, menus, progress bars, or TextUI.
- Client needs to call server (or server calls client): use
lib.callback/lib.callback.awaitandlib.callback.register. - Registering server commands with help and params: use
lib.addCommand. - Keybinds, context menus, skill checks, locales, or shared helpers (lib.table, lib.string, etc.).
- Zones: “when player enters/leaves area”, “is player inside” — use
lib.zones.poly,lib.zones.box,lib.zones.sphere(prefer client; server has limited support for onEnter/onExit/inside).
Setup
- In
fxmanifest.lua:shared_scripts { '@ox_lib/init.lua' }. Optional:ox_libs { 'locale', 'callback', ... }to preload modules.
Rules
Read the rule that matches what you're doing:
- rules/init.md — Adding ox_lib to fxmanifest, shared_script, ox_libs.
- rules/callback.md — Client↔server:
lib.callback,lib.callback.await,lib.callback.register. - rules/interface.md — UI:
lib.notify,lib.alertDialog,lib.inputDialog; icons (Font Awesome 6). - rules/addCommand.md — Server commands:
lib.addCommandwith help, params, restricted. - rules/zones.md — Zones:
lib.zones.poly,lib.zones.box,lib.zones.sphere; onEnter, onExit, inside; remove, contains, setDebug.
References (look up if not covered in the rules above)
If something isn't covered in the rules above, check the official docs:
- Ox Lib (index): https://coxdocs.dev/ox_lib
- Interface (notify, alert, input, menu, progress, textui): https://coxdocs.dev/ox_lib/Modules/Interface
- Callback (client/server): https://coxdocs.dev/ox_lib/Modules/Callback/Lua/Server and …/Client
- AddCommand: https://coxdocs.dev/ox_lib/Modules/AddCommand/Server
- Zones: https://coxdocs.dev/ox_lib/Modules/Zones/Shared
- AddKeybind: https://coxdocs.dev/ox_lib/Modules/AddKeybind/Client
- Locale, Table, String, Math, etc.: navigate from https://coxdocs.dev/ox_lib
Frequently asked questions
- Yes. ox_lib is standalone and does not depend on a framework. Both ESX and QBCore servers use it, and the FiveAI skills for those frameworks recommend it for notifications, dialogs and menus.
- Yes. ox_lib is open source and published on GitHub under the LGPL license. You can use it on any server without paying, as long as you respect the license terms.
- Yes, with a manual step. The SKILL.md is plain markdown, so you can paste it into the conversation as context. Native skill support is for Claude Code, Cursor and VS Code.
Does ox_lib work with ESX and QBCore?
Is ox_lib free?
Can I use this skill with ChatGPT?
Related guides
Longer reads from the FiveAI blog on the same topic.