Installation

Start a new app, add UiContext to an existing one, or install into one package of a monorepo.

Start a new app

  1. Create a Vite app

    npm create vite@latest my-app -- --template vanilla-ts
    cd my-app
  2. Pin Effect UI

    Add these overrides to package.json so every item uses the same Effect UI build. Bun needs them before add.

    {  "overrides": {    "@effect/ui": "https://pkg.pr.new/Effect-TS/ui/@effect/ui@9d672ab",    "effect": "4.1.7"  }}
  3. Add the app setup

    This installs vite.config.ts with StyleX, src/base.css, tsconfig.uicontext.json, the WebMCP polyfill for development and the lock script.

    npx shadcn@latest add checkfu/uicontext/app-setup

    Then point tsconfig.json at the shared settings:

    {  "extends": "./tsconfig.uicontext.json",  "include": ["src"]}
  4. Add the bootstrap and the shell

    npx shadcn@latest add checkfu/uicontext/app-bootstrap checkfu/uicontext/app-shell
  5. Write the routes, the app and the entry

    src/routes.ts lists the pages. Claim and Join open 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.ts says what each route shows and what frames it. Sign-in comes first, on /api/auth/*; move it with auth: { paths: "/auth" }, or pass auth: false until 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.ts starts it. Replace the template's main.ts with it in index.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>
  6. Run it

    npm run dev

    Your 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.ts
  7. Add your first component

    pnpm dlx shadcn@latest add checkfu/uicontext/form-controls
    import { 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-setup
  1. Vite

    Add the StyleX plugin to your config. Keep useCSSLayers and the empty targets, which keep light-dark() colors as written.

    import stylex from "@stylexjs/unplugin"export default defineConfig({  plugins: [    stylex.vite({ devMode: "full", useCSSLayers: true, lightningcssOptions: { targets: {} } }),    // your other plugins  ],})
  2. Base stylesheet

    Copy the @layer priority1 { … } reset and the color-scheme rules from src/base.css into your stylesheet. Rules outside that layer win over every component style.

  3. TypeScript

    Extend tsconfig.uicontext.json, or set strict, exactOptionalPropertyTypes, verbatimModuleSyntax and allowImportingTsExtensions, with ES2023 and DOM in lib.

  4. Entry

    Import ./ui/uicontext/app-setup/webmcp.ts first in your entry, then your stylesheet.

  5. Your own root

    Keep your root component and add the gate where the app starts. Your session routes go in authPathsLayer, or in createApp's auth.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 source
  1. Pin versions once, at the root

    Put the overrides and a version catalog in the root package.json. Each package then takes catalog: 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:"  }}
  2. Mark the app's package

    Add components.json to apps/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"  }}
  3. 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.

Updating

Install everything

Every component, theme and helper at once.

pnpm dlx shadcn@latest add checkfu/uicontext/all
App Bootstrap API