CLI reference
The apex command.
One CLI covers the whole lifecycle — develop, generate, migrate, build, serve, and inspect your MCP tools. Every command and flag below is from the source.
Overview #
apex ships with @apex-stack/core. Install it globally
(npm i -g @apex-stack/core) and apex works in any project; otherwise it's a
project-local binary wired to npm scripts (npm run dev) or run via npx apex.
| Command | What it does |
|---|---|
apex new | Scaffold a new app, install dependencies, and init git. |
apex dev | Start the development server (SSR + hydrate, API + MCP, hot reload). |
apex build | Prerender pages to deployable HTML + client bundles. |
apex start | Run a production build made with apex build --server. |
apex make | Generate a page, component, or API route. |
apex migrate | Apply pending SQL migrations. |
apex mcp | Inspect the local MCP server — list or call tools. |
apex new #
Scaffold a new Apex JS app in a new directory — then install dependencies and initialize a git repo.
apex new [dir] [--no-install] [--no-git]
| Argument / flag | Default | Description |
|---|---|---|
dir (positional) | apex-app | Target directory for the new app. |
--no-install | installs | Skip installing dependencies. |
--no-git | inits git | Skip initializing a git repository. |
No global install? npm create apexjs@latest my-app runs the same scaffolder via
npx, then use npm run dev.
apex dev #
Start the Apex JS development server.
apex dev [root] [--port <n>] [--islands]
| Argument / flag | Default | Description |
|---|---|---|
root (positional) | . | Project root. |
--port | 3000 | Port to listen on. |
--islands | false | Render in islands mode (static-first). See Islands. |
apex dev
apex dev --port 4000
apex dev --islands
apex build #
Prerender pages to deployable HTML plus per-page client bundles.
apex build [root] [--outDir <dir>] [--islands] [--server]
| Argument / flag | Default | Description |
|---|---|---|
root (positional) | . | Project root. |
--outDir | dist | Output directory. |
--islands | false | Static-first islands mode (zero-JS static site). |
--server | false | Build a Node server (dynamic routes + API/MCP). Pair with apex start. |
apex build # prerender + hydrate → static dist/
apex build --islands # zero-JS static site (SSG)
apex build --server # deployable Node server target
The three modes are explained in full on Build & deploy.
apex start #
Run a production build produced by apex build --server (no Vite).
apex start [dir] [--port <n>]
| Argument / flag | Default | Description |
|---|---|---|
dir (positional) | dist | Build directory (must contain apex-manifest.json). |
--port | 3000 | Port to listen on. |
apex build --server && apex start
apex make #
Generate a page, component, or API route from a template.
apex make <kind> <name> [--root <dir>]
| Argument / flag | Default | Description |
|---|---|---|
kind (positional) | — | page | component | api (required). |
name (positional) | — | Name, e.g. about, Counter, todos (required). |
--root | . | Project root. |
| Kind | Creates |
|---|---|
page | pages/<name>.alpine — a loader + x-data template + scoped style. |
component | components/<name>.alpine — a small interactive component. |
api | server/api/<name>.ts — a defineApexRoute that's REST + MCP. |
apex make page about
apex make component Counter
apex make api todos
Fails if the target file already exists (it won't overwrite your work).
apex migrate #
Apply pending SQL migrations from db/migrations/*.sql (idempotent). Resolves @apex-stack/data from your app.
apex migrate [--db <file>] [--driver <d>] [--url <url>] [--dir <dir>] [--root <dir>]
| Flag | Default | Description |
|---|---|---|
--db | data.db | SQLite file path (libSQL). |
--driver | sqlite | sqlite | postgres | pglite. |
--url | — | Connection URL (Postgres) — overrides --db. |
--dir | db/migrations | Migrations directory. |
--root | . | Project root. |
apex migrate
apex migrate --driver postgres --url $DATABASE_URL
See Data → Migrations.
apex mcp #
Inspect the local MCP server — list its tools or call one. Reuses the bundled MCP SDK (nothing to install).
apex mcp [--url <url>] [--call <name>] [--args <json>]
| Flag | Default | Description |
|---|---|---|
--url | http://localhost:3000/mcp | MCP endpoint URL. |
--call | — | Name of a tool to call. Omit to list all tools. |
--args | {} | JSON arguments for --call. |
apex mcp # list tools + signatures
apex mcp --call add --args '{"a":2,"b":3}'
Requires a running dev server. More on AI-native → inspector.
create-apexjs #
The scaffolder (a separate, unscoped package) — the entry point for a new project.
npm create apexjs@latest [dir] # dir defaults to "apex-app"
It copies the default template, renames _gitignore → .gitignore, substitutes the project name, and prints next steps. See Getting started.