Run the CLI and hand it a project directory:
pnpm exec loom preview ~/code/my-gameYou don’t add anything to the project: no vite.config.ts, no index.html, no entry changes. The
directory doesn’t need its own node_modules either.
To get the same thing from your own Vite config, see Vite integration.
A complete project from scratch
No roblox-ts project yet? These three files are enough to render:
my-preview/├── package.json├── vite.config.ts└── src/ └── main.client.tsx{ "name": "my-preview", "private": true, "type": "module", "scripts": { "dev": "vite", "build": "vite build" }, "devDependencies": { "@loom-dev/preview": "^0.13.2", "react": "^18.3.1", "vite": "^6.0.0" }}import { loomPreview } from "@loom-dev/preview/vite";import { defineConfig } from "vite";
export default defineConfig({ plugins: [loomPreview()] });import { useState } from "@rbxts/react";import { createRoot } from "@rbxts/react-roblox";
function App() { const [count, setCount] = useState(0);
return ( <screengui> <frame AnchorPoint={new Vector2(0.5, 0.5)} Position={UDim2.fromScale(0.5, 0.5)} Size={UDim2.fromOffset(260, 140)} BackgroundColor3={Color3.fromRGB(28, 30, 36)} > <uicorner CornerRadius={new UDim(0, 12)} /> <uipadding PaddingTop={new UDim(0, 20)} PaddingBottom={new UDim(0, 20)} PaddingLeft={new UDim(0, 20)} PaddingRight={new UDim(0, 20)} /> <uilistlayout FillDirection={Enum.FillDirection.Vertical} HorizontalAlignment={Enum.HorizontalAlignment.Center} VerticalAlignment={Enum.VerticalAlignment.Center} Padding={new UDim(0, 12)} />
<textlabel Text={`clicked ${count} times`} Size={new UDim2(1, 0, 0, 24)} BackgroundTransparency={1} Font={Enum.Font.GothamBold} TextSize={18} TextColor3={Color3.fromRGB(236, 238, 244)} /> <textbutton Text="click me" Size={new UDim2(1, 0, 0, 40)} BackgroundColor3={Color3.fromRGB(64, 118, 246)} Font={Enum.Font.GothamBold} TextSize={15} TextColor3={Color3.fromRGB(255, 255, 255)} Event={{ Activated: () => setCount((n) => n + 1) }} > <uicorner CornerRadius={new UDim(0, 8)} /> </textbutton> </frame> </screengui> );}
createRoot().render(<App />);pnpm install && pnpm viteOpen the printed URL. You get a rounded card with a label and a blue button, and the count goes up
when you click. Edits to main.client.tsx hot-reload.
You never import UDim2, Color3, Enum or Vector2. The plugin installs them as globals before
your entry runs.
The project renders, but your editor redlines @rbxts/react, UDim2 and the lowercase elements.
TypeScript setup fixes that.
What the plugin looks for
With no index.html, the plugin generates a page and loads the first entry it finds from this list:
src/main.client.tsxsrc/main.client.tssrc/client/main.client.tsxsrc/client/main.client.tssrc/main.tsxsrc/main.tssrc/index.tsxsrc/client.tsxA normal roblox-ts project already matches one. If yours doesn’t, name it with the plugin’s entry
option. If the project has its own index.html, loom uses it, and its <script type="module">
decides what loads.
When there is neither, the CLI exits instead of serving a blank page:
loom: no index.html and no client entry found in /Users/you/code/my-game looked for: src/main.client.tsx, src/main.client.ts, src/client/main.client.tsx, ... (or pass --targets to browse *.loom.tsx files as a gallery)The entry must mount itself
Loom doesn’t call your component for you. The entry mounts at the top level, the way a roblox-ts client script does:
import { createRoot } from "@rbxts/react-roblox";import { App } from "./App";
createRoot().render(<App />);createRoot() ignores the Roblox target you pass, so you can keep
Players.LocalPlayer.WaitForChild("PlayerGui") and use the same entry in Studio and in the preview.
If nothing mounts within two seconds, loom logs this. It usually means the entry exports a component instead of rendering it:
[loom] nothing mounted into #loom-root after 2s — does your entry call createRoot().render(<App />) at the top level?For vide, call mount:
import { mount } from "@rbxts/vide";import { App } from "./App";
mount(App);Preview many components at once
For a browsable list of components, name files *.loom.tsx, export a preview object from each,
and pass --targets:
export const preview = { render: () => ( <textbutton Text="click me" Size={new UDim2(0, 160, 0, 40)} BackgroundColor3={Color3.fromRGB(64, 118, 246)} TextColor3={Color3.fromRGB(255, 255, 255)} /> ), title: "Button",} as const;pnpm exec loom preview . --targetsEach scene gets a sidebar entry and its own error boundary. No client entry is needed.
loom build --targets emits the same gallery as a static site. See
Gallery targets.
Flags
loom preview [dir] [--port <n>] [--host] [--targets [glob]]dir defaults to .. --host binds all interfaces, or the address you pass after it. An optional
<dir>/loom.config.ts can set targets, port and shims; flags win. See the
CLI reference.
Next step
Scope and status lists what loom renders faithfully and what it ignores. To run the preview from your own Vite project, see Vite integration.