mri-fivem-skills
All skills

mri-nui-cef

NUI on FiveM's CEF

Building and fixing FiveM NUI pages for the Chromium that FiveM actually runs.

The NUI is an embedded Chromium (CEF) drawn off screen over the game. It is not the browser you test in: a bug that only shows in game is often a version difference.

Which Chromium

CEF 103 limits (until everyone is on 144)

CEF 144: what breaks

Scan everything at once:

node scripts/cef-scan.mjs <resources folder> --src-only

--src-only skips dist/, build/ and minified bundles (report the source, rebuild).

Change Fix
alert(), confirm() removed your own modal, or hold-to-confirm
document.execCommand('copy') needs the element focused el.focus() before el.select(); templates/clipboard.ts
fx_version 'adamant'/'bodacious' or __resource.lua: the page may not be a secure context fx_version 'cerulean' (nothing else changes for the Lua)
Mutation events (DOMNodeInserted, DOMSubtreeModified) removed MutationObserver
CSS zoom follows the standard test clicks, drag and popover positions inside zoomed areas; prefer transform: scale()
Many requests in a row are throttled batch fetchNui calls, no fast polling (events from Lua instead)
new URL() throws on <, >, | encode user input
Mic and camera only in the resource's own page, not in iframes inside it request them in the top page
WebUSB, Bluetooth, HID, Serial, printing, picture-in-picture blocked none
Cookies expire after 400 days at most keep state in the server or KVP

CEF 144: what opens up

Working rules

Testing in the browser

Logs

The NUI console.log and its errors go to the client log: FiveM.app/logs/CitizenFX_log_*.log in the FiveM install folder. Bug only in game: log the state with an easy prefix, reproduce, read that file.