Docs/Dirk CFX React/Getting Started

Getting Started

Dirk CFX React

Installation

Install dirk-cfx-react in your resource's web/ folder:

shell
pnpm add dirk-cfx-react

Wrap Your App

In your resource's root React component, wrap everything in DirkProvider:

tsx
import { DirkProvider } from "dirk-cfx-react";
import { AdminPanel } from "./components/Admin/main";

function App() {
  return (
    <DirkProvider>
      <AdminPanel />
    </DirkProvider>
  );
}

DirkProvider handles:

  • Mantine theme setup with dark mode and VH-based sizing
  • Fetching server settings (currency, colours, item image path, game type)
  • Font loading (Akrobat family)
  • Error boundary wrapping
  • NUI ready signal (NUI_READY callback)

Build Setup

Your resource's web/ folder should use Vite as the build tool. A typical Vite config:

ts
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import path from "path";

export default defineConfig({
  plugins: [react()],
  base: "./",
  build: {
    outDir: "build",
    emptyOutDir: true,
  },
  resolve: {
    alias: {
      "@": path.resolve(__dirname, "./src"),
    },
  },
});

Build command:

shell
cd web
pnpm run build

The output goes to web/build/ which is served by FiveM's NUI system.


Importing

Everything is exported from the top-level package:

tsx
import {
  SettingsPanel,
  AdminPageTitle,
  AsyncSaveButton,
  InputContainer,
  SelectItem,
  FiveMKeyBindInput,
  Modal,
  ConfirmModal,
  useNuiEvent,
  fetchNui,
  locale,
  useForm,
  useFormField,
  useFormActions,
  FormProvider,
  createScriptSettings,
  DirkProvider,
} from "dirk-cfx-react";

You can also import from sub-paths if you prefer:

tsx
import { SettingsPanel } from "dirk-cfx-react/components";
import { useForm } from "dirk-cfx-react/hooks";
import { fetchNui } from "dirk-cfx-react/utils";
import { DirkProvider } from "dirk-cfx-react/providers";
Was this page helpful?
This page was last updated on 15 March 2026
DIRKSCRIPTS
All you need for your FiveM server.10% off your first order

Unsubscribe any time.

Copyright © 2026 DirkScripts. Not affiliated with or endorsed by Rockstar North or Take-Two Interactive.