Start a new app, add UiContext to an existing one, or install into one package of a monorepo.
Start a new app
Create a Vite app
npm create vite@latest my-app -- --template vanilla-tscd my-appPin Effect UI
Add these
overridestopackage.jsonso every item uses the same Effect UI build. Bun needs them beforeadd.{ "overrides": { "@effect/ui": "https://pkg.pr.new/Effect-TS/ui/@effect/ui@9d672ab", "effect": "4.1.7" }}Add the app setup
This installs
vite.config.tswith StyleX,src/base.css,tsconfig.uicontext.json, the WebMCP polyfill for development and the lock script.npx shadcn@latest add checkfu/uicontext/app-setupThen point
tsconfig.jsonat the shared settings:{ "extends": "./tsconfig.uicontext.json", "include": ["src"]}Add the bootstrap and the shell
npx shadcn@latest add checkfu/uicontext/app-bootstrap checkfu/uicontext/app-shellWrite the routes, the app and the entry
src/routes.tslists the pages.ClaimandJoinopen the owner's claim link and invitations.import { Route } from "@effect/ui"import { Schema } from "effect"export const AppRoute = Route.union({ Home: Route.make("/"), Claim: Route.make("/claim", { search: { code: Schema.optional(Schema.String) } }), Join: Route.make("/join/:id", { params: { id: Schema.String }, search: { code: Schema.optional(Schema.String) }, }), NotFound: Route.make("/*"),})src/app.tssays what each route shows and what frames it. Sign-in comes first, on/api/auth/*; move it withauth: { paths: "/auth" }, or passauth: falseuntil your server has those routes.import { createApp } from "./ui/uicontext/components/app/createApp.ts"import { AppShell } from "./ui/uicontext/components/kit/AppShell.ts"import { AppRoute } from "./routes.ts"export const app = createApp({ routes: AppRoute, page: (h, { route, me }) => AppRoute.match(route, { Home: () => h.h1.children(`Hello, ${me.name}`), Claim: () => h.h1.children("Welcome"), Join: () => h.h1.children("Welcome"), NotFound: () => h.h1.children("Page not found"), }), shell: (h, { page }) => AppShell(h, { props: { label: "Workspace" }, onEmit: () => undefined, slots: { sidebar: h.nav.children(h.a.attr("href", "/").children("Home")), main: page }, }),})src/entry.tsstarts it. Replace the template'smain.tswith it inindex.html:import "./ui/uicontext/app-setup/webmcp.ts"import "./base.css"import { app } from "./app.ts"app.run()<div id="app"></div><script type="module" src="/src/entry.ts"></script>Run it
npm run devYour app now has these files:
my-app/├─ index.html├─ package.json overrides for @effect/ui and effect├─ tsconfig.json extends tsconfig.uicontext.json├─ tsconfig.uicontext.json app-setup├─ vite.config.ts app-setup├─ scripts/│ └─ uicontext-lock.ts app-setup└─ src/ ├─ base.css app-setup ├─ entry.ts app.run() ├─ app.ts createApp({ … }) ├─ routes.ts AppRoute └─ ui/uicontext/ installed source you own ├─ app-setup/webmcp.ts └─ components/ ├─ app/createApp.ts └─ kit/AppShell.tsAdd your first component
pnpm dlx shadcn@latest add checkfu/uicontext/form-controlsimport { FormField, Input } from "./ui/uicontext/components/FormControls.ts"Home: () => FormField(h, { id: "project", label: "Project name" }, (attrs) => Input(h).attrs({ ...attrs, name: "project", required: "" }), ),
Add to an existing app
Install the setup without --overwrite. The CLI skips the files you already have, so merge these by hand:
npx shadcn@latest add checkfu/uicontext/app-setupVite
Add the StyleX plugin to your config. Keep
useCSSLayersand the emptytargets, which keeplight-dark()colors as written.import stylex from "@stylexjs/unplugin"export default defineConfig({ plugins: [ stylex.vite({ devMode: "full", useCSSLayers: true, lightningcssOptions: { targets: {} } }), // your other plugins ],})Base stylesheet
Copy the
@layer priority1 { … }reset and thecolor-schemerules fromsrc/base.cssinto your stylesheet. Rules outside that layer win over every component style.TypeScript
Extend
tsconfig.uicontext.json, or setstrict,exactOptionalPropertyTypes,verbatimModuleSyntaxandallowImportingTsExtensions, withES2023andDOMinlib.Entry
Import
./ui/uicontext/app-setup/webmcp.tsfirst in your entry, then your stylesheet.Your own root
Keep your root component and add the gate where the app starts. Your session routes go in
authPathsLayer, or increateApp'sauth.paths.import { Me, SignOut, authPathsLayer } from "./ui/uicontext/components/kit/Session.ts"import { AuthGate } from "./ui/uicontext/components/app/AuthGate.ts"// in your root componentqueries: { me: { query: Me, args: () => ({}) } },view: (h, { route }) => AuthGate(h, { session: h.queries.me, arrival: { _tag: "SignIn" }, signedIn: (me) => Shell(h, { key: me.id, props: { route, me } }), }),// and its Layers, with your session routesexport const App = AppNoDeps.pipe( Component.provide(Layer.mergeAll(Me.layer, SignOut.layer).pipe(Layer.provideMerge(authPathsLayer("/auth")))),)
Install into a monorepo
Run the CLI with --cwd set to the app's package. Files land beside that package's components.json. Items import each other by relative path, so your aliases don't affect them.
acme/├─ package.json workspaces, catalog and overrides└─ apps/ └─ web/ ├─ components.json marks the package the CLI installs into ├─ package.json ├─ tsconfig.json ├─ vite.config.ts └─ src/ui/uicontext/ installed sourcePin versions once, at the root
Put the overrides and a version catalog in the root
package.json. Each package then takescatalog:versions.{ "private": true, "workspaces": { "packages": ["apps/*", "packages/*"], "catalog": { "@effect/ui": "https://pkg.pr.new/Effect-TS/ui/@effect/ui@9d672ab", "effect": "4.1.7", "@stylexjs/stylex": "0.19.2", "@stylexjs/unplugin": "0.19.2", "vite": "8.3.8" } }, "overrides": { "@effect/ui": "https://pkg.pr.new/Effect-TS/ui/@effect/ui@9d672ab", "effect": "4.1.7" }}{ "name": "@acme/web", "dependencies": { "@effect/ui": "catalog:", "effect": "catalog:", "@stylexjs/stylex": "catalog:" }}Mark the app's package
Add
components.jsontoapps/web. Its aliases can be anything your tools use.{ "tsx": true, "rsc": false, "aliases": { "components": "@/components", "ui": "@/components/ui", "lib": "@/lib", "utils": "@/lib/utils", "hooks": "@/hooks" }}Install into the package
npx shadcn@latest add --cwd apps/web checkfu/uicontext/app-setup checkfu/uicontext/app-bootstrap
Pin a revision
Add # and a commit SHA to an item to install it as it was at that commit, with every file it imports. Record what you installed in uicontext.lock.json so updates show up as diffs.
Install everything
Every component, theme and helper at once.
pnpm dlx shadcn@latest add checkfu/uicontext/all