> For the complete documentation index, see [llms.txt](https://cylexdev.gitbook.io/docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://cylexdev.gitbook.io/docs/cylex-phone/exports-and-events/adding-custom-apps/exports.md).

# Exports

Client-Side Exports

#### AddCustomApp <a href="#user-content-addcustomapp" id="user-content-addcustomapp"></a>

Adds a custom application to the phone's interface dynamically.

```lua
-- options: table - A table containing the application configuration.
---- appId: string - The unique identifier for the custom application.
---- label: string - The display name of the application on the phone screen.
---- icon: string - The URL or path to the application's icon image.
---- ui: string - The URL or NUI route where the application's UI is hosted.
-- return: boolean, string - Returns true if added successfully, otherwise false and an error message.

-- Programmatically registers a new application in the phone system.
-- Ideal for integrating external scripts with their own UI into the phone.
function loadApp()
     local resourceName = GetCurrentResourceName()
     local data = {
        appId = "my_custom_app",
        label = "My Application",
        -- You can use an external URL or your script's local NUI path for the icon
        icon = ("https://cfx-nui-%s/html/app_icon.png"):format(resourceName),
        -- The NUI/HTML file where your application is hosted
        ui = ("https://cfx-nui-%s/html/index.html"):format(resourceName),
    }
    AddEventHandler('cylex_phone:client:phoneLoaded', function()
        exports["cylex_phone"]:AddCustomApp(data)  
    end)
    exports["cylex_phone"]:AddCustomApp(data)  
end
```

#### RemoveCustomApp <a href="#user-content-sendcustomnuimessage" id="user-content-sendcustomnuimessage"></a>

Manually remove a registered custom application from the phone.

```lua
-- appId: string - The unique identifier of the custom application to remove.
-- return: boolean, string - Returns true if successful, otherwise false and an error message.

-- Removes the app from the home screen and unloads its iframe.
-- If the user is currently viewing the app, they are redirected to home.

local success, errMessage = exports["cylex_phone"]:RemoveCustomApp("my_custom_app")

if success then
    print("Custom app removed successfully!")
else
    print("Failed to remove app: " .. tostring(errMessage))
end
```

#### SendCustomNUIMessage <a href="#user-content-sendcustomnuimessage" id="user-content-sendcustomnuimessage"></a>

Send a targeted NUI message directly to a registered custom application.

```lua
-- appId: string - The unique identifier of the target custom application.
-- data: table - The payload data table to send to the application's UI.
-- return: boolean, string - Returns true if successful, otherwise false and an error message.

-- Allows external scripts to communicate with their custom apps running inside the phone UI.
-- Useful for updating dynamic content, routing, or triggering specific actions in the app UI.

-- The data table can contain anything your custom app's NUI is expecting to receive.
local success, errMessage = exports["cylex_phone"]:SendCustomNUIMessage("my_custom_app", {
    action = "refreshData",
    activeCount = 15,
    status = "online"
})

if success then
    print("NUI Message routed to custom app successfully!")
else
    print("Failed to dispatch message: " .. tostring(errMessage))
end
```

#### ToggleFocusKeepInput <a href="#user-content-sendcustomnuimessage" id="user-content-sendcustomnuimessage"></a>

If you don't want the character to walk while typing in the input field, call this export as `false` the moment the input field is clicked (gains focus), and when the user clicks elsewhere (loses focus).

```lua
-- focusMode: boolean - Set false if you don't want to use random key while typing.
exports["cylex_phone"]:ToggleFocusKeepInput(false)
```
