More Premium Hugo Themes Premium React Themes

Fivem React Boilerplate Lua

Basic Lua & React (TypeScript) boilerplate for FiveM

Fivem React Boilerplate Lua

Basic Lua & React (TypeScript) boilerplate for FiveM

Author Avatar Theme by project-error
Github Stars Github Stars: 243
Last Commit Last Commit: May 7, 2024 -
First Commit Created: Apr 29, 2023 -
Fivem React Boilerplate Lua screenshot

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.

Installation:

To install the boilerplate, follow these steps:

  1. Clone the repository or use the template option and place it within your resources folder.
  2. Navigate to the web folder within a terminal of your choice.
  3. Type npm i or yarn to install the dependencies.

Summary:

This article introduces a boilerplate for React in NUI, providing utilities and examples to aid in browser and in-game based development workflows. It includes features such as Lua utilities, React utilities, and miscellaneous utilities, and provides instructions for installation.