Custom apps

Tablet Custom App Template

Template for creating external apps for the tablet system (mad-tablet).

πŸ“‹ Prerequisites

  • Node.js installed

  • npm or yarn

  • The mad-tablet resource must be installed and working

πŸš€ How to use

1. Install dependencies

cd web-source
npm install

2. Build the web application

npm run build

This will create the web folder with the compiled files.

3. Configure the resource

The resource is already configured to automatically register on the tablet when it starts.

⚠️ IMPORTANT: If you change the resource name, you must update the name in the file web-source/src/utils/fetchNui.ts:

4. Add to server.cfg

5. Test

  1. Start the server

  2. Enter the game

  3. Open the tablet (F5 or /tablet command)

  4. You should see the "Custom App" in the apps list

  5. Click on the app to open it

🎨 Customize the App

Change name, icon and color

Edit the file client/main.lua:

Change the UI

Edit the files in web-source/src/components/App.tsx and then build again.

Add visibility logic

In client/main.lua, you can add conditions to show/hide the app:

πŸ“ Structure

πŸ”§ Available exports

The template already implements the necessary exports:

  • onAppOpen() - Called when the app is opened

  • onAppClose() - Called when the app is closed

πŸ“¨ Send messages from Lua to React

To send messages from Lua to React in your external app, use the sendReactMessage export from the tablet:

⚠️ IMPORTANT: The iframeId must be exactly the same as the id you used in RegisterApp. For example, if you registered with id = 'custom-app-template', you must use iframeId = 'custom-app-template'.

In React, receive the message like this:

Reference Script

https://github.com/fmsfdd/tablet_custom_app_template

πŸ“ Notes

  • The app registers automatically when the resource starts

  • The web build must be done whenever you change code in web-source

  • For development, you can use npm run start:game for watch mode

Last updated