Require

Library
Updated 2 months ago · v1.3.7
i

Shared Module

lib.require

Loads, caches, and returns a module. Detects circular dependencies. Searches native require, then package.preload, then file-based loading.

lua
local utils = lib.require('utils')
local remote = lib.require('@otherResource.shared.helpers')
ParameterTypeRequiredDescription
modNamestringyesModule name. Prefix with @resourceName. to load from another resource

Returns: module return value (cached after first load)

lib.load

Loads and runs a Lua file. Unlike require, the result is not cached — the file is executed every time.

lua
local result = lib.load('shared/config')
local bridgeResult = lib.load('bridge/keys/qbx', nil, true)
ParameterTypeRequiredDescription
filePathstringyesPath to the Lua file
envtablenoCustom environment for the loaded chunk
bridgebooleannoIf true, returns false instead of erroring when the file is not found

lib.loadJson

Loads and decodes a JSON file.

lua
local config = lib.loadJson('config/settings')
ParameterTypeRequiredDescription
filePathstringyesPath to the JSON file

lib.loadBridge

Loads a bridge module for a specific resource and context.

lua
local keysBridge = lib.loadBridge('keys', 'qb-vehiclekeys', 'client')
ParameterTypeRequiredDescription
_typestringyesBridge category (e.g. 'keys', 'fuel', 'inventory')
resourcestringyesTarget resource name
_contextstringyes'client' or 'server'

Loads from @dirk_lib.bridge.{_type}.{resource}.{_context}. Returns {} if the bridge file is not found.

Package System

The module system provides a package table compatible with Lua conventions:

FieldDescription
package.path'./?.lua;./?/init.lua'
package.preloadTable for pre-registered modules
package.loadedRead-only view of the module cache
package.searchpath(name, path)Searches for a file matching the template pattern
Was this page helpful?
This page was last updated on 12 March 2026
DIRKSCRIPTS
All you need for your FiveM server.10% off your first order

Unsubscribe any time.

Copyright © 2026 DirkScripts. Not affiliated with or endorsed by Rockstar North or Take-Two Interactive.