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.
Install the package with bun add elm-ssr, then run commands with bun elm-ssr <command> from the workspace root.
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
Two commands serve different purposes: init sets up a single-app project in the current directory; new adds an app to an existing workspace.
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.
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.
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
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
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
SQL-file migrations run in alphabetical order, each transactionally. elm-ssr query generates type-safe Elm modules from your schema.
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
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).
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.
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
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/.