Examples

The examples/ folder is a staircase. Start near the bottom, change something small, and climb when you are curious.

The staircase

Each folder has a short README. Paths below are from the repository root.

ExampleWhat you will learn
examples/01_hello_worldThe smallest selm program. Great for checking that the CLI works.
examples/02_counterA tiny HTTP server with a supervised counter. Plain text plus HTML from the ui package. No Postgres.
examples/03_todo_appFull-stack: multi-page SPA, Cowboy API, Postgres, cookies, row security, and migrations.
examples/04_conduitA larger RealWorld-style app split into API and web packages.
examples/05_chatA websocket lobby. The channel module is shared by the BEAM process and the SPA. No database.
examples/06_atomvm_helloHello on AtomVM: selm on a microcontroller board.
examples/07_mcp_searchAn MCP client with a local fake search server and HTTP search. See AI.
examples/08_acp_agentA browser workspace for Cursor and Claude Code over ACP. No database. See AI.
examples/09_webgl_triangleA JS WebGL triangle with [glsl| … |] and elm-explorations/webgl.
examples/10_randomDice on both sides: browser Random and BEAM Random (generate / step) over HTTP.
examples/11_hydrateSame TEA view SSR into #app with Server.page, then JS Browser.element hydrate.
examples/12_selm_syntaxLanguage surface samples used by the docs and compiler checks.
examples/13_csv_booksHTTP CSV round-trip: multipart upload streams through Csv.decode into Postgres.
examples/14_ws_books_uploadWebsocket row / binary streaming with StreamUpload.handleIn: chunked Ups (including Bytes), immediate Error, final Finished.
examples/15_jobsDurable Jobs + job module (enqueue over HTTP, SQLite selm_jobs, retries, cron).
examples/16_svgJS Svg mark from the first-party selm/svg hard stack. Also a Language tour step.
examples/17_time_formatLive Time.format clock + Duration. Also a Language tour step.
examples/18_emailVerification tokens with Email and a welcome message rendered by Email.Mjml.
examples/19_service_workerWorker.Service register plus Cache Storage (cachePut / match / delete / clear).
examples/20_cloudflare_workerFetch.Handler ES module for Cloudflare Workers (wrangler dev / node smoke.mjs).
examples/21_durable_counterWorkers Server.application: gate TEA, reply-Subject call / askMap, nests / startChild / Temporary, alarms, Storage / Env, SQLite, forward / withFetch, derived durable codecs, selmMailbox.
examples/22_durable_chatWorkers Channels: Server.Socket.supervised + Server.Channel.define with explicit JSON codecs on hibernatable Durable Object WebSockets (contrast BEAM 05_chat).
examples/23_mcp_serverAn MCP server: a Platform.worker echoes tools/call on stdin/stdout. See AI.
examples/uiA shared .selm view package used by both BEAM SSR and the JS SPA.

Commands to try

Todo (needs local Postgres):

cd examples/03_todo_app
selm serve

Counter (no database):

cd examples/02_counter
selm run

Svg or Time.format (browser):

cd examples/16_svg
selm dev

Durable Objects (Workers, no Wrangler account needed for smoke):

cd examples/21_durable_counter
selm make && selm wrangler check && node smoke.mjs

cd examples/22_durable_chat
selm make && node smoke.mjs