All the commands.

Install the package with bun add elm-ssr, then run commands with bun elm-ssr <command> from the workspace root.

Quick reference
elm-ssr build
elm-ssr compress
elm-ssr dev
elm-ssr new <name>
elm-ssr init <name>
elm-ssr migrate up|down|status
elm-ssr route <path>
elm-ssr query
elm-ssr routes
elm-ssr info
Project setup

Create a project.

Two commands serve different purposes: init sets up a single-app project in the current directory; new adds an app to an existing workspace.

elm-ssr init <name>

Single-app project in the current directory.

Generates elm-ssr.config.json with root: ".", a runtime.ts, starter routes, and an island.

elm-ssr init my-app
elm-ssr init my-app --db
elm-ssr init my-app --auth betterAuth
  • --db

    Configures local SQLite via bun:sqlite, creates migrations/0001_init.sql.

  • --auth betterAuth|auth0

    Adds session + CSRF middleware, Login.elm, Profile.elm, and an auth callback. Enables --db automatically.

elm-ssr new <name>

Add an app to an existing workspace.

Scaffolds under <workspace>/<name>/ and registers the app in the existing elm-ssr.config.json. Name must match ^[a-z0-9-]+$.

elm-ssr new my-app
elm-ssr new my-app --in apps
elm-ssr new my-app --db
elm-ssr new my-app --auth betterAuth
  • --in <subdir>

    Places the app under <workspace>/<subdir>/<name>/.

  • --db

    Configures SQLite and generates an initial migration.

  • --auth betterAuth|auth0

    Scaffolds auth middleware and authed routes. Enables --db automatically.

elm-ssr build

Scan, generate, and compile.

For each configured app: scans Routes/ and Islands/, generates the router and island manifest, syncs Elm authoring modules, then runs elm make. Output lands in generated/<app-root>/.

elm-ssr build
elm-ssr compress

Build and gzip for the edge.

Same pipeline as build, but additionally gzips the generated bundles so the edge can serve Content-Encoding: gzip directly. Use this for production deploys.

elm-ssr compress
elm-ssr dev

Build then start wrangler dev.

Runs build then wrangler dev for a local Cloudflare-flavoured environment. For other providers, run elm-ssr build and start your own Fetch handler.

elm-ssr dev
Database

Migrations and query generation.

SQL-file migrations run in alphabetical order, each transactionally. elm-ssr query generates type-safe Elm modules from your schema.

elm-ssr migrate

Run, revert, or inspect migrations.

Reads DATABASE_URL from the environment if --db is omitted.

elm-ssr migrate up
elm-ssr migrate down
elm-ssr migrate down --count 3
elm-ssr migrate status

elm-ssr migrate up --db ./app.db
elm-ssr migrate up --db sqlite://./app.db
elm-ssr migrate up --db postgres://user:pass@host/db

elm-ssr migrate up --dir ./db/migrations
elm-ssr migrate up --table schema_history
elm-ssr query

Generate type-safe Elm Db modules.

Reads SQL table definitions from the migrations directory and outputs phantom-typed Elm modules with column descriptors, decoders, and CRUD builders.

elm-ssr query
elm-ssr query --app my-app
elm-ssr query --dir ./db/migrations
elm-ssr query --output ./src/Database
  • --app <name>

    Required in multi-app workspaces.

  • --dir <path>

    Overrides migrations directory (default: <app_root>/migrations).

  • --output <path>

    Overrides where Elm modules are written (default: <app_root>/src/<Module>/Db).

elm-ssr route <path>

Scaffold a new route or endpoint.

Scaffolds an Elm page route by default. Use flags to generate a JSON API action, a WebSocket handler, or an SSE stream instead.

elm-ssr route blog/post
elm-ssr route api/users --api
elm-ssr route chat --ws
elm-ssr route feed --sse
elm-ssr route contact --app my-app
  • --api

    Scaffolds a JSON API action route.

  • --ws

    Scaffolds a TypeScript WebSocket handler under src/Endpoints/.

  • --sse

    Scaffolds a TypeScript SSE stream handler under src/Endpoints/.

  • --app <name>

    Required in multi-app workspaces.

elm-ssr routes / elm-ssr info

Inspect the workspace.

routes prints each configured app with its module and routes directory. info prints the workspace package name and configured app names.

elm-ssr routes
elm-ssr info
elm-ssr.config.json

Workspace configuration.

Lives at the workspace root. Lists all apps. A global --root <path> flag overrides where the CLI looks for this file.

{
  "apps": [
    {
      "name":   "my-app",
      "root":   "apps/my-app",
      "module": "MyApp"
    }
  ]
}
  • name

    Short identifier used in generated/<name>/ paths.

  • root

    App directory, relative to workspace root.

  • module

    Root Elm namespace (period-separated). MyApp expects src/MyApp/Routes/, src/MyApp/Islands/.