UI Architecture
Technology Stack
Mythic resources use two UI stacks depending on age:Legacy UIs
React 17 + Redux + ThunkUsed by: HUD, Inventory, MDT, Laptop, most existing resources
Modern UIs
React 18 + Zustand + TypeScriptUsed by: New Phone UI (
ui-new/), newer resources- Material-UI v5 — Component library
- Emotion — CSS-in-JS styling
- Webpack 5 — Module bundler
UI Resources
mythic-hud
Health, armor, status bars, vehicle info, minimap, notifications
mythic-phone
Smartphone with contacts, messages, calls, email, camera, apps
mythic-inventory
Drag-and-drop inventory, tooltips, crafting, shops
mythic-mdt
Police MDT — warrants, person/vehicle lookup, dispatch, reports
mythic-laptop
Laptop interface with email, documents, browser
mythic-characters
Character creation, appearance customization, selection
mythic-menu
Context menus with nested submenus and keyboard navigation
mythic-chat
In-game chat with commands
Client-UI Communication
Lua to React (SendNUIMessage)
React to Lua (NUI Callbacks)
Communication Flow
Custom Hooks
useNuiEvent
Simplify NUI message handling:State Management
Redux (Legacy UIs)
Zustand (Modern UIs)
Best Practices
NUI Focus Management
NUI Focus Management
Always manage NUI focus properly in Lua:
ESC Key Handling
ESC Key Handling
Always handle ESC to close UI:
Visibility Control
Visibility Control
Don’t render hidden UIs — return null:
Performance
Performance
Optimize React rendering:
Building UIs
Built UI files go into
dist/ which is referenced by ui_page in fxmanifest.lua. Always run npm run build before testing in-game.Next Steps
Resource Structure
How UI fits into resource organization
Component System
Server/client components that power UIs
Event System
Events that trigger UI updates
HUD API
HUD component API reference