Skip to content

Your First Project

Scaffold a React project and add Floe:

Terminal window
npm create vite@latest my-app -- --template react-ts
cd my-app
npm install
npm install -D @floeorg/vite-plugin
vite.config.ts
import { defineConfig } from "vite"
import react from "@vitejs/plugin-react"
import floe from "@floeorg/vite-plugin"
export default defineConfig({
plugins: [
floe(), // must come before React plugin
react(),
],
})

Add allowArbitraryExtensions and rootDirs to tsconfig.json so TypeScript can resolve .fl imports:

{
"compilerOptions": {
"allowArbitraryExtensions": true,
"rootDirs": ["./src", "./.floe/src"]
}
}

Create src/Counter.fl:

import { useState } from "react"
export let Counter() -> JSX.Element = {
let (count, setCount) = useState(0)
<div>
<p>Count: {count}</p>
<button onClick={() -> setCount(count + 1)}>+1</button>
</div>
}

Import it from your existing TypeScript:

src/App.tsx
import { Counter } from "./Counter.fl"
function App() {
return <Counter />
}
Terminal window
npm run dev

Vite compiles .fl files on the fly. HMR works automatically.

For backend apps, scripts, or non-Vite projects, use @floeorg/register to resolve .fl imports at runtime, and floe watch to keep compiled output fresh.

Terminal window
npm install -D @floeorg/register

Add rootDirs to your tsconfig.json so TypeScript resolves .fl imports through the .floe/ output:

{
"compilerOptions": {
"allowArbitraryExtensions": true,
"rootDirs": ["./src", "./.floe/src"]
}
}
{
"scripts": {
"dev": "floe watch src/ & node --import @floeorg/register src/app.ts",
"build": "floe build src/"
}
}

The --import @floeorg/register flag teaches Node how to resolve .fl imports. It redirects them to the compiled .ts/.tsx output in .floe/. Works with node (v22.14+), tsx, and any Node-based runtime.

floe watch recompiles .fl files to .floe/ on change. Run it alongside your app:

Terminal window
# Single command (as in the script above)
npm run dev
# Or in separate terminals
floe watch src/ # Terminal 1
node --import @floeorg/register src/app.ts # Terminal 2

Run floe build before your build step:

Terminal window
floe build src/
# then your normal build

Run the checker without generating output:

Terminal window
floe check src/