Loomgetting started

Your first preview

Preview a roblox-ts project with the loom CLI and no config, or start one from scratch.

Run the CLI and hand it a project directory:

Preview a project
pnpm exec loom preview ~/code/my-game

You 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:

Project layout
my-preview/
├── package.json
├── vite.config.ts
└── src/
└── main.client.tsx
package.json
{
"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"
}
}
vite.config.ts
import { loomPreview } from "@loom-dev/preview/vite";
import { defineConfig } from "vite";
export default defineConfig({ plugins: [loomPreview()] });
src/main.client.tsx
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 />);
Run it
pnpm install && pnpm vite

Open 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.

What the plugin looks for

With no index.html, the plugin generates a page and loads the first entry it finds from this list:

Entry candidates, in priority order
src/main.client.tsx
src/main.client.ts
src/client/main.client.tsx
src/client/main.client.ts
src/main.tsx
src/main.ts
src/index.tsx
src/client.tsx

A 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:

No entry found
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:

src/main.client.tsx
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:

src/main.client.ts (vide)
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:

src/scenes/Button.loom.tsx
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;
Browse every scene under the project
pnpm exec loom preview . --targets

Each 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.