-
Notifications
You must be signed in to change notification settings - Fork 0
Installation
This guide covers the steps required to install and configure @nrbx/react in a roblox-ts project.
Before installing @nrbx/react, make sure your project meets the following requirements:
- Node.js 18 or newer
- npm, pnpm, or yarn available in your environment
-
roblox-ts3.x or newer with TypeScript 5.x - Rojo 7.x or newer
- A Roblox project already set up for
roblox-ts
If you already have a roblox-ts project running with Rojo and TypeScript configured, you are ready to add @nrbx/react.
Install the core package and the Roblox renderer:
npm install @nrbx/react @nrbx/react-roblox
# or
pnpm add @nrbx/react @nrbx/react-roblox
# or
yarn add @nrbx/react @nrbx/react-robloxOptional packages can be added when you want extra tooling or compatibility helpers:
npm install @nrbx/react-is @nrbx/scheduler @nrbx/react-devtoolsMost projects only need:
-
@nrbx/react— the React-compatible runtime and JSX layer -
@nrbx/react-roblox— the Roblox mounting/rendering runtime
The easiest way to configure your project is to extend the @nrbx/react-tsconfig preset:
npm install @nrbx/react-tsconfig
# or
pnpm add @nrbx/react-tsconfig
# or
yarn add @nrbx/react-tsconfigThen in your tsconfig.json:
{
"extends": "@nrbx/react-tsconfig"
}That's it — the preset includes JSX, React import source, Roblox types, and path aliases.
| Preset | Extends From | Use Case |
|---|---|---|
@nrbx/react-tsconfig |
.tsconfig.json |
Default: full React JSX + path aliases |
@nrbx/react-tsconfig/tsconfig.base.json |
— | No JSX, minimum settings. Use for packages or build tooling. |
@nrbx/react-tsconfig/tsconfig.strict.json |
tsconfig.json |
Full React JSX + strict checks (noUnusedLocals, noUnusedParameters, exactOptionalPropertyTypes, etc.) |
@nrbx/react-tsconfig/tsconfig.client.json |
tsconfig.json |
React JSX, scoped to src/client/**/*. Use for client-only workspaces. |
@nrbx/react-tsconfig/tsconfig.server.json |
tsconfig.base.json |
No JSX, scoped to src/server/**/*. Use for server-only workspaces. |
If you prefer to configure manually, @nrbx/react works with standard roblox-ts JSX settings.
{
"compilerOptions": {
"target": "ESNext",
"module": "commonjs",
"moduleResolution": "Node16",
"strict": true,
"jsx": "react-jsx",
"jsxImportSource": "@nrbx/react",
"types": ["@rbxts/types"],
"lib": ["ESNext"],
"rootDir": "src",
"outDir": "out"
}
}{
"compilerOptions": {
"jsx": "react",
"jsxFactory": "React.createElement",
"jsxFragmentFactory": "React.Fragment",
"types": ["@rbxts/types"]
}
}-
"jsx": "react"or"jsx": "react-jsx"are both valid - If you use
react-jsx, set"jsxImportSource": "@nrbx/react" -
"types": ["@rbxts/types"]ensures Roblox Instance and global type definitions are available
If your project includes a types folder or custom type declarations, make sure those Roblox types are still available to the compiler.
In most roblox-ts projects, the important piece is this:
{
"compilerOptions": {
"types": ["@rbxts/types"]
}
}No additional type packages are required for @nrbx/react itself — the package ships with its own TypeScript definitions.
A typical project layout looks like this:
src/
client/
main.client.tsx # React entry point
shared/
components/ # Shared components
server/ # Server code (no React)
This keeps your React UI in src/client while leaving server scripts separate.
Create a client script that mounts a React tree into a Roblox ScreenGui or other container.
// src/client/main.client.tsx
import React from "@nrbx/react";
import { createRoot } from "@nrbx/react-roblox";
function App() {
return (
<textlabel
Text="Hello from @nrbx/react"
Size={new UDim2(1, 0, 0, 40)}
BackgroundTransparency={1}
TextColor3={Color3.fromRGB(255, 255, 255)}
/>
);
}
const container = script.Parent!.WaitForChild("ScreenGui") as ScreenGui;
const root = createRoot(container);
root.render(<App />);This mounts your first React tree into a Roblox UI container. You can swap the container with PlayerGui, a Folder, or another valid Roblox Instance as needed.
@nrbx/react supports optional configuration through defineConfig(). This is useful if you want custom colors, spacing scales, or theme defaults.
// src/shared/style.config.ts
import { defineConfig } from "@nrbx/react";
export default defineConfig({
colors: {
brand: {
50: Color3.fromRGB(239, 246, 255),
500: Color3.fromRGB(59, 130, 246),
900: Color3.fromRGB(30, 58, 138),
},
},
spacing: {
// custom spacing scale
},
});You can then import and use your configured style system as your project grows.
After installing the package, verify everything is working before building a larger UI.
Run the compiler:
npx rbxtscIf there are no TypeScript errors, the package has been resolved correctly.
Run Rojo and open the place in Roblox Studio. Make sure the compiled output is being synced to the expected place.
Use a minimal component to confirm the UI renders:
import React from "@nrbx/react";
import { createRoot } from "@nrbx/react-roblox";
const root = createRoot(script.Parent!.WaitForChild("ScreenGui") as ScreenGui);
function HelloWorld() {
return <textlabel Text="Hello World" Size={new UDim2(0, 200, 0, 40)} />;
}
root.render(<HelloWorld />);If the label appears in Roblox Studio, the installation is working correctly.
If something does not work as expected, check the following:
- "Cannot find module @nrbx/react" — make sure the package is installed in the project and that
node_modulesis present - "JSX element type does not have construct signature" — verify the
jsxconfig is set correctly and matches the runtime you are using - "Cannot find name 'React'" — import React explicitly in your component files
- Build errors about
require— this is usually handled correctly byroblox-ts3.x; confirm yourroblox-tsversion is up-to-date - Rojo not finding built files — check the
outDirin yourtsconfig.jsonand verify Rojo is watching the correct output folder - Missing Roblox types — ensure
@rbxts/typesis included incompilerOptions.types
Once your project is installed and compiling, you can start building components, using hooks, and rendering Roblox UI trees with @nrbx/react.
For the next step, move on to your first real UI component and connect it to a ScreenGui or PlayerGui root.