ox_lib for FiveM: what it is, common mistakes and the AI skill

View on skills.sh

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.notify for notifications, lib.alertDialog for confirmations, lib.inputDialog for forms, plus context menus, progress bars and TextUI. Icons come from Font Awesome 6.
  • Callbacks. lib.callback.register on the server, lib.callback.await on the client. The client asks, the server answers, and you get the value back on the same line.
  • Commands. lib.addCommand on the server with help, params and restricted, so the command validates its arguments and checks permissions for you.
  • Zones. lib.zones.poly, lib.zones.box and lib.zones.sphere with onEnter, onExit and inside handlers. Use them on the client. The server side has limited support.
  • Utilities. Keybinds, locales, lib.table, lib.string and other shared modules.

The full reference is at coxdocs.dev/ox_lib.

Common mistakes with ox_lib

  • Forgetting @ox_lib/init.lua in the manifest. The script loads and then dies with "attempt to index a nil value (global 'lib')". Add shared_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 with lib.callback.register on 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_lib calls, old ESX menus and custom NUI for a simple confirm dialog are all signs of code written before ox_lib existed. Replace them with lib.alertDialog, lib.inputDialog and 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

  1. Click "Download SKILL.md" at the top of this page.
  2. 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.
  3. 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.register on the server and lib.callback.await on 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.

Claude Code skills docs

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.

Cursor rules docs

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.

VS Code custom instructions docs

The SKILL.md file

This is the file your AI assistant reads. It links to the rule files bundled in the download.

Skill contents (includes SKILL.md and any other files)

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.await and lib.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.addCommand with 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:

Frequently asked questions

Does ox_lib work with ESX and QBCore?
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.
Is ox_lib free?
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.
Can I use this skill with ChatGPT?
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.

Longer reads from the FiveAI blog on the same topic.

More skills