This boilerplate provides a modern React setup specifically designed for FiveM development.
- Fast Build System: Powered by Vite for quick and efficient development.
- UI Library: Built with Mantine UI to ensure a visually appealing interface.
- Flexible Workflows: Supports both browser and in-game development, making it versatile for various scenarios.
- CfxLua Runtime Compatibility: Seamlessly integrates with the CfxLua runtime for FiveM applications.
The boilerplate was built pnpm but is still compatible with npm.
- Clone the repository or use the template option and place it within your
resourcesfolder. - Go to the
webfolder within a terminal of your choice and typepnpm iornpm i.
- (
pnpmornpm)run dev– Starts the development server. - (
pnpmornpm)run build– Builds the project. - (
pnpmornpm)run build:watch– Builds the project and watches for changes. - (
pnpmornpm)run build:clean– Deletes the./builddirectory.
// `VisibilityProvider` is a component that manages the visibility state of its children.
// Example:
<VisibilityProvider component='MDTComponent'>
<MDTComponent/>
</VisibilityProvider>// Triggers a callback registered with the REGISTER_NUI_CALLBACK native.
// Example:
TriggerNuiCallback<any>('getPlayerInfo').then(info => {
setPlayerInfo(info);
});// `HandleNuiMessage` is a hook that listens for events sent from the client and invokes a handler when an event with the specified action is received.
// Example:
const [playerData, setPlayerData] = useState<PlayerData>([]);
HandleNuiMessage<any>('updatePlayerData', (data) => {
setPlayerData(data);
});// Example:
// Triggers the `HandleNuiMessage` hook registered with the action `setVisibleApp`, passing `true` as the data payload to control the visibility of the application.
// This stimulates the SEND_NUI_MESSAGE native in the development environment.
SendNuiMessage([
{action: 'setVisibleApp', data: true}
]);-- 1st argument its the message sent by SEND_NUI_MESSAGE native.
-- 2nd argument sets the SET_NUI_FOCUS native value.
-- Example:
handleNuiMessage({action = 'setVisibleApp', data = true}, true)