{"id":19472093,"url":"https://github.com/antonstjernquist/react-fivem-hooks","last_synced_at":"2025-04-25T12:31:21.323Z","repository":{"id":57237608,"uuid":"372467127","full_name":"antonstjernquist/react-fivem-hooks","owner":"antonstjernquist","description":"Essential React hooks for FiveM NUI development written in Typescript","archived":false,"fork":false,"pushed_at":"2024-09-20T19:57:05.000Z","size":146,"stargazers_count":9,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T21:51:11.791Z","etag":null,"topics":["fivem","fivem-script","hook","react","reactjs","typescript"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/antonstjernquist.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-05-31T10:26:07.000Z","updated_at":"2024-11-28T06:54:03.000Z","dependencies_parsed_at":"2023-01-18T03:30:30.376Z","dependency_job_id":null,"html_url":"https://github.com/antonstjernquist/react-fivem-hooks","commit_stats":null,"previous_names":["antonstjernquist/fivem-hooks"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonstjernquist%2Freact-fivem-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonstjernquist%2Freact-fivem-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonstjernquist%2Freact-fivem-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/antonstjernquist%2Freact-fivem-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/antonstjernquist","download_url":"https://codeload.github.com/antonstjernquist/react-fivem-hooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250129123,"owners_count":21379648,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["fivem","fivem-script","hook","react","reactjs","typescript"],"created_at":"2024-11-10T19:12:27.936Z","updated_at":"2025-04-25T12:31:20.766Z","avatar_url":"https://github.com/antonstjernquist.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n[![code type](https://img.shields.io/npm/types/react-fivem-hooks)](https://github.com/antonstjernquist) [![action](https://github.com/antonstjernquist/react-fivem-hooks/actions/workflows/publish.yml/badge.svg)](https://github.com/antonstjernquist/react-fivem-hooks/actions/workflows/publish.yml) [![npm version](https://img.shields.io/npm/v/react-fivem-hooks)](https://www.npmjs.com/package/react-fivem-hooks) [![downloads](https://img.shields.io/npm/dw/react-fivem-hooks?color=%2334D058)](https://www.npmjs.com/package/react-fivem-hooks) \n\n# React FiveM Hooks\n\nEssential React hooks for FiveM NUI development written in Typescript\n\n## Install the package\n```yarn add react-fivem-hooks```\n\n## Wrap the component in the provider\n```Typescript\nimport { NuiProvider } from 'react-fivem-hooks';\n\nReactDOM.render(\n  \u003cNuiProvider\u003e\n    \u003cApp /\u003e\n  \u003c/NuiProvider\u003e,\n  document.getElementById('root')\n);\n```\n\n## useNuiEvent\n```Typescript\nimport { useNuiEvent } from 'react-fivem-hooks';\n\nexport const Component = () =\u003e {\n  const { data: isOpen } = useNuiEvent\u003cboolean\u003e({ event: 'SET_NUI_OPEN' });\n\n  return (\n    \u003cdiv\u003e\n      \u003cspan\u003e{isOpen ? 'Profit.' : 'Closed.'}\u003c/span\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n## Send the event (Browser console)\n```Javascript\n// Should display \"Profit.\"\nwindow.postMessage({ type: 'SET_NUI_OPEN', payload: true });\n  \n  \n// Should display \"Closed.\"\nwindow.postMessage({ type: 'SET_NUI_OPEN', payload: false });\n```\n\n\n## useDisableControls (Disable input movement)\n#### Generic hook to disable movement in FiveM when typing inside a input field.\n\n**Note**: This feature requires the `nui-controls` library to be used on the client.\n\n```Typescript\nimport { useDisableControls } from 'react-fivem-hooks';\n\nexport const Component = () =\u003e {\n  const { controls } = useDisableControls();\n\n  return (\n    \u003cdiv\u003e\n      \u003cinput placeholder=\"Yay, I don't move\" {...controls} /\u003e\n    \u003c/div\u003e\n  );\n}\n```\n\n\n## nui-controls (lua client library)\n#### This is a resource included in this repository which you can utilise to easily disable controls when using input fields in your NUI.\n\n1. Download `nui-controls` from this repository.\n2. Put it in your server folder.\n3. Add it to the resource you want to use the `useDisableControls`-hook like this:\n\n```LUA\nclient_scripts {\n  '@nui-controls/client.lua',\n  '...',\n}\n```\n\n4. Now you can utilise `useDisableControls` in your NUI.\n\n\n### Disclaimer\n\"react-fivem-hooks\" are not affiliated, associated, authorized, endorsed by, or in any way officially connected with the FiveM™ trademark, or any of its subsidiaries or its affiliates. The official FiveM™ website can be found at https://fivem.net/\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonstjernquist%2Freact-fivem-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fantonstjernquist%2Freact-fivem-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fantonstjernquist%2Freact-fivem-hooks/lists"}