molo modding

Buildan app

Put your script inside Molo Folio, like housing scripts do with LB Phone. A few lines in your fxmanifest.lua show the app, and a few lines of Lua answer it.

Needs
molo_phone 2.4.0+
You write
HTML / JS + Lua
Frameworks
Any
Time
About 10 minutes
The example My Home app: its icon on the home screen, then the app in light and dark mode with doors and shared keys

How it works

An app is a normal FiveM resource. The phone finds it on its own, shows its icon, and opens its page inside the phone.

  1. Your fxmanifest.lua declares the app Name, icon, colour and the page to open. No Lua is needed to make the icon appear.
  2. Your page is plain HTML and JavaScript It loads the Molo Folio SDK and UI kit, so it looks like the built-in apps, in light and dark mode.
  3. Your Lua answers the page RegisterAppCallback('name', fn) on the server (or client), and await MoloPhone.server('name', data) in the page. That is the whole bridge.

Start from the template. molo_folio_app_template.zip is a complete working app ("My Home": doors, GPS, key sharing). Copy it, rename it, change what you need.

Quick start

3 files
  1. Declare the app in fxmanifest.lua List your page files in files so the phone can load them.
    fx_version 'cerulean'
    game 'gta5'
    
    molo_folio_app 'ui/index.html'
    molo_folio_app_name 'My Home'
    molo_folio_app_icon 'ui/icon.png'        -- or an emoji: '🏠'
    molo_folio_app_color '#ff9f0a'           -- optional
    molo_folio_app_description 'Lock your doors and share your keys.'   -- optional
    
    server_script 'server.lua'
    files { 'ui/index.html', 'ui/app.js', 'ui/icon.png' }
    dependency 'molo_phone'
  2. Make the page Load the UI kit and the SDK from molo_phone, then write your app.
    <link rel="stylesheet" href="https://cfx-nui-molo_phone/html/sdk/molo-phone-ui.css">
    <script src="https://cfx-nui-molo_phone/html/sdk/molo-phone-sdk.js"></script>
    
    <main class="mp-app">
      <h1 class="mp-title">My Home</h1>
      <div class="mp-section">Doors</div>
      <div class="mp-list" id="doors"></div>
    </main>
    <script src="app.js"></script>
    MoloPhone.onReady(async () => {
      const doors = await MoloPhone.server('getDoors');
      document.querySelector('#doors').innerHTML = doors.map((d) =>
        `<div class="mp-row"><div class="mp-row-main"><div class="mp-row-title">${d.label}</div></div></div>`).join('');
    });
  3. Answer it from your server Whatever the function returns goes back to the page.
    exports.molo_phone:RegisterAppCallback('getDoors', function(source, data, phone)
        -- source = player id, data = what the page sent, phone.number = '555-1234'
        return { { id = 1, label = 'Front door' }, { id = 2, label = 'Garage' } }
    end)

Then add it to server.cfg after the phone and restart:

ensure molo_phone
ensure my_home_app

The icon appears on every phone. Players can remove it or add it back from the App Store, under Third-party apps.

The SDK

molo-phone-sdk.js
CallWhat it does
MoloPhone.onReady(info => …)Runs when the app opens. info.number, info.name, info.dark, info.lang, info.wide (unfolded), info.folded.
await MoloPhone.server(name, data)Calls your server RegisterAppCallback(name, …) and returns its result.
await MoloPhone.client(name, data)Calls your client RegisterAppCallback(name, …): waypoints, animations, anything on the player's side.
MoloPhone.notify(title, text)Shows a phone notification with your app's icon.
await MoloPhone.contacts()The player's contacts: [{ name, number }].
await MoloPhone.pickMedia({ video })Lets the player pick a photo (or video) from the gallery or the camera. Returns { url }.
MoloPhone.onMessage(data => …)Receives what your Lua sends with SendCustomAppMessage (live updates).
MoloPhone.close()Goes back to the home screen.

If a callback does not exist, MoloPhone.server and MoloPhone.client throw an error you can catch, so a typo shows up in the F8 console instead of failing silently.

UI kit

molo-phone-ui.css

The stylesheet gives your page the phone's fonts, colours and components. Dark mode follows the player's setting on its own.

ClassUse it for
mp-app, mp-header, mp-title, mp-subtitle, mp-backPage, large title, back button
mp-section, mp-list, mp-row (mp-row-ic, mp-row-main, mp-row-title, mp-row-sub, mp-row-end, mp-chevron)Grouped lists like the Settings app
mp-btn + primary / success / danger / block / small, mp-actionsButtons
mp-toggleOn/off switch: <label class="mp-toggle"><input type="checkbox"><span></span></label>
mp-card, mp-grid, mp-badge (green, red, blue)Cards, tiles, status labels
mp-input, mp-search, mp-field, mp-labelForms
mp-empty, mp-spinner, mp-mutedEmpty states and loading

Colours are CSS variables (--mp-accent, --mp-green, --mp-red, --mp-card…), so you can use them in your own styles.

Example: a housing app

The template is a small housing app. To plug in a real housing or keys script, keep the page and replace the demo data in server.lua with calls to that script.

exports.molo_phone:RegisterAppCallback('setLocked', function(source, data)
    -- call your door script here, for example:
    exports.ox_doorlock:setDoorState(data.id, data.locked and 1 or 0)
    return { ok = true }
end)

exports.molo_phone:RegisterAppCallback('shareKey', function(source, data, phone)
    local target = exports.molo_phone:GetSourceFromNumber(data.number)
    -- give the key with your keys script here
    if target then
        exports.molo_phone:SendNotification(target, { title = 'My Home', content = phone.number .. ' gave you a key' })
    end
    return { ok = true }
end)

The same pattern works for a music player for music you made yourself, a job board, a business app, a racing app, and so on.

Lua reference

Server

exports.molo_phone:RegisterAppCallback(name, function(source, data, phone) return result end)
exports.molo_phone:SendNotification(src, { title = '...', content = '...' })
exports.molo_phone:GetPhoneNumber(src)
exports.molo_phone:GetSourceFromNumber('555-1234')

Client

exports.molo_phone:RegisterAppCallback(name, function(data) return result end)
exports.molo_phone:SendCustomAppMessage('my_home_app', { type = 'refresh' })   -- MoloPhone.onMessage in the page
exports.molo_phone:IsOpen()

Adding the app from Lua instead of the fxmanifest

Useful if the app should only appear for some players (a job, an item…). Paths are relative to your resource.

exports.molo_phone:AddCustomApp({ id = 'my_home_app', name = 'My Home', icon = 'ui/icon.png', ui = 'ui/index.html' })
exports.molo_phone:RemoveCustomApp('my_home_app')

With the fxmanifest method, the app id is your resource name.

Tips