> 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/client-exports/custom-app.md).

# Custom App

#### 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.

local resourceName = GetCurrentResourceName()
local success, errMessage = exports["cylex_phone"]:AddCustomApp({
    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),
})

if success then
    print("Application successfully registered to the phone!")
else
    print("Error registering 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
```
