ESXshared
exports['es_extended']:getSharedObject
ESX shared documentation with a FiveM Lua example.
Summary
Gets the ESX shared object. On ESX 1.9+ this export is the correct, current way — replacing the old TriggerEvent pattern.
Returns
table — the ESX object.
Example
ESX = exports['es_extended']:getSharedObject()
-- Old, deprecated (causes nil ESX on 1.9+):
-- TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)Common pitfalls
- Using the old TriggerEvent pattern on ESX 1.9+ is the #1 cause of 'attempt to index a nil value (global ESX)'.
- Call this at the top of your client and server files before using ESX.
Related functions
Related guides
FiveM scripts done right
Optimized, dual-framework scripts for QBCore and ESX from Viper Development — escrow protected, delivered instantly to your Cfx portal.
Browse Scripts →