This boilerplate is very bare bones, so it's easy to edit and add new things.
- Vite for building and dev tooling
- zustand for easy state-management.
- TailwindCSS for styling the pages.
- Mantine for customizable components
- FiveM Integration
Gets data from the FiveM Client.
Parameters
-
endpoint
(Type: String): A string that points to the intended endpoint, e.g., "whoami". -
data
(Type: Object): An object with the data to be sent (Optional when not using a callback). -
cb
(Type: Function): A callback that returns the result of the function.
React.js app (With Callback)
SendNuiCallback('whoami', {}, (res) => {
// do something with the data
})
React.js app (Without Callback)
SendNuiCallback('whoami')
Registers a callback on the FiveM Client to call from the UI.
Parameters
-
endpoint
(Type: String): A string that points to the intended endpoint, e.g., "whoami". -
data
(Type: Object): An object with the data recieved from the SendNuiCallback. -
cb
(Type: Function): A callback that returns some data to the SendNuiCallback.
FiveM Script (Client)
RegisterNUICallback("whoami", function(data, cb)
cb('fivem client')
end)
Sends data to the UI from the FiveM Client.
Parameters
-
type
(Type: String): A string that specifies the type of update to perform. It has the following preset values:showUI
: Displays the UI.hideUI
: Hides the UI and triggers a callback to unfocus the UI.
-
data
(Type: Object): An object with the data to send.
FiveM Script (Client)
SendNUIMessage({
type = "showUI",
data = {
value = "FiveM Value"
}
})
Clone this repository.
git clone https://github.com/Zuntie/reactjsfivem-boilerplate
Install NPM dependencies.
npm install
Build the application in /web
cd web
npm run build
Automatic builds, that only require a restart of the resource
cd web
npm run build:watch
MIT License
Copyright (c) 2024 Zuntie
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.