⚠️ AlabJS is under active development and not yet production-ready. APIs may change before v1.0. Feel free to explore, contribute, or star the repo.
Skip to content

The alab CLI is installed locally in your project. Run it via your package manager's script runner or node_modules/.bin/alab.

Commands

alab dev

Starts the development server with hot module replacement.

bash
alab dev
alab dev --port 4000
alab dev --host 0.0.0.0
FlagDefaultDescription
--port3000Port to listen on
--hostlocalhostHost to bind

The dev server:

  • Compiles TypeScript with the Rust/oxc compiler
  • Runs Vite HMR for instant CSS and component updates
  • Streams SSR using renderToPipeableStream
  • Enforces server/client boundaries at dev time
  • Shows rich error overlays with Rust-sourced line numbers

alab build

Builds the app for production.

bash
alab build
alab build --mode spa
alab build --analyze
alab build --skip-typecheck
FlagDefaultDescription
--modessrBuild mode: ssr or spa
--analyzefalseOpen bundle size treemap after build
--skip-typecheckfalseSkip tsc --noEmit

SSR mode (default): Outputs a Node.js server bundle to .alabjs/dist/. Requires a Node.js runtime to serve.

SPA mode: Outputs a static index.html + hashed assets to .alabjs/dist/spa/. Deployable to any CDN. Server functions become fetch calls to /_alabjs/fn/* — point these at a separate API server.

The --analyze flag requires rolldown-plugin-visualizer or rollup-plugin-visualizer to be installed:

bash
pnpm add -D rolldown-plugin-visualizer

alab start

Serves the production build.

bash
alab start
PORT=8080 alab start
Environment VariableDefaultDescription
PORT3000HTTP port
HOST0.0.0.0Bind address
PUBLIC_URLPublic base URL (for sitemap + CSRF)

Must run alab build before alab start.


alab ssg

Pre-renders static routes to HTML files.

bash
alab ssg

SSG renders all routes without dynamic segments. For dynamic routes, export generateStaticParams from the page:

ts
// app/posts/[slug]/page.tsx
export async function generateStaticParams() {
  const posts = await db.posts.findMany({ select: { slug: true } });
  return posts.map((p) => ({ slug: p.slug }));
}

alab test

Runs tests with Vitest.

bash
alab test
alab test --watch
alab test --ui
FlagDefaultDescription
--watchfalseRe-run tests on file changes
--uifalseOpen the Vitest UI in the browser

You can also pass file paths to run a subset of tests:

bash
alab test src/utils.test.ts

alab info

Prints the route manifest, server functions, and boundary violations for the current project.

bash
alab info

Output includes:

  • Route manifest — all discovered routes, their kind (page / api / layout), and SSR status
  • Server functions — every defineServerFn export and its generated POST endpoint
  • Boundary violations — client files that illegally import server modules at runtime

Global flags

FlagShortDescription
--cwd <path>-CSet the project root — useful in monorepos
--help-hShow help
--version-vShow version

--cwd is resolved relative to the directory where the CLI is invoked, so both absolute and relative paths work:

bash
# From the monorepo root
alab dev --cwd apps/marketing
alab build -C apps/dashboard
alab start --cwd /absolute/path/to/app

Environment variables

VariableCommandsDescription
PORTdev, startHTTP port
HOSTdev, startBind address
NODE_ENVAlldevelopment in dev, production in start
PUBLIC_URLstart, ssgCanonical base URL for sitemap + CSRF cookie
ALAB_TYPECHECKbuildSet to 0 to skip typecheck (same as --skip-typecheck)

Programmatic API

The CLI commands are also exported as functions for use in custom scripts:

ts
import { build, dev, ssg } from "alabjs/commands";

await build({ cwd: process.cwd(), mode: "ssr", analyze: false });
await ssg({ cwd: process.cwd() });

Released under the MIT License.