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-tabletresource must be installed and working
π How to use
1. Install dependencies
cd web-source
npm install2. Build the web application
npm run buildThis 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
Start the server
Enter the game
Open the tablet (F5 or
/tabletcommand)You should see the "Custom App" in the apps list
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 openedonAppClose()- 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-sourceFor development, you can use
npm run start:gamefor watch mode
Last updated