Fivem React Boilerplate Lua

screenshot of Fivem React Boilerplate Lua
react

Basic Lua & React (TypeScript) boilerplate for FiveM

Overview:

The content is providing an introduction to a boilerplate for getting started with React in NUI. It is designed for both browser and in-game based development workflows and includes utilities and examples to work off of.

Features:

  • Lua Utils:

    • SendReactMessage: A wrapper for dispatching NUI messages, designed to be used with the useNuiEvent React hook.
    • debugPrint: A debug printing utility dependent on a convar, which prints out to the console if the convar is set.
  • React Utils:

    • useNuiEvent: A custom React hook for intercepting and handling messages dispatched by game scripts.
    • fetchNui: A NUI focused wrapper around the standard fetch API, used for active NUI data fetching or triggering NUI callbacks in game scripts.
    • debugData: A function allowing for mocking dispatched game script actions in a browser environment, triggering useNuiEvent handlers as if they were dispatched by the game scripts.
  • Misc Utils:

    • isEnvBrowser(): Returns a boolean indicating if the current environment is a regular browser, useful for logic in development.
react
React

React is a widely used JavaScript library for building user interfaces and single-page applications. It follows a component-based architecture and uses a virtual DOM to efficiently update and render UI components

typescript
Typescript

TypeScript is a superset of JavaScript, providing optional static typing, classes, interfaces, and other features that help developers write more maintainable and scalable code. TypeScript's static typing system can catch errors at compile-time, making it easier to build and maintain large applications.