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.

CommandWhat it does
apex newScaffold a new app, install dependencies, and init git.
apex devStart the development server (SSR + hydrate, API + MCP, hot reload).
apex buildPrerender pages to deployable HTML + client bundles.
apex startRun a production build made with apex build --server.
apex makeGenerate a page, component, or API route.
apex migrateApply pending SQL migrations.
apex mcpInspect 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 / flagDefaultDescription
dir (positional)apex-appTarget directory for the new app.
--no-installinstallsSkip installing dependencies.
--no-gitinits gitSkip 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 / flagDefaultDescription
root (positional).Project root.
--port3000Port to listen on.
--islandsfalseRender 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 / flagDefaultDescription
root (positional).Project root.
--outDirdistOutput directory.
--islandsfalseStatic-first islands mode (zero-JS static site).
--serverfalseBuild 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 / flagDefaultDescription
dir (positional)distBuild directory (must contain apex-manifest.json).
--port3000Port 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 / flagDefaultDescription
kind (positional)page | component | api (required).
name (positional)Name, e.g. about, Counter, todos (required).
--root.Project root.
KindCreates
pagepages/<name>.alpine — a loader + x-data template + scoped style.
componentcomponents/<name>.alpine — a small interactive component.
apiserver/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>]
FlagDefaultDescription
--dbdata.dbSQLite file path (libSQL).
--driversqlitesqlite | postgres | pglite.
--urlConnection URL (Postgres) — overrides --db.
--dirdb/migrationsMigrations 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>]
FlagDefaultDescription
--urlhttp://localhost:3000/mcpMCP endpoint URL.
--callName 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.