Skip to content

Run the live poll

Run the first checkpoint of the live-poll tutorial on your machine. The example includes the Gleam server, Ewe WebSocket transport, and browser client, so you do not need to assemble a server from snippets.

  • Gleam 1.19.2 and Erlang 27 or 28
  • Git and a browser
  • Internet access to download dependencies and load the Phoenix JavaScript client

You do not need Node.js or a separate frontend build for this example.

Terminal window
git clone https://github.com/tylerbutler/beryl.git
cd beryl/examples/live_poll
gleam deps download

If you already have a clone, change to its examples/live_poll directory.

Terminal window
gleam run -m live_poll/step_01

Keep the server running and open http://localhost:8101. Leave the room as demo and select Join poll. You should see an open poll with zero votes. The browser joins the poll:demo topic and requests the current state over the WebSocket connection.

This checkpoint is read-only. Voting and Close poll now do not change the poll, and their requests time out. You will add voting and broadcasts in chapter 2.

Stop the server with Ctrl-C before you run another checkpoint.

Start with chapter 1: The Elm architecture, without a DOM. You will learn how beryl handles state, inputs, and effects, then add voting and typed server messages to the same app.

The tutorial starts with raw dispatch to show the core model. For most new apps, use channel handlers. In chapter 4, you will move the poll to that API without changing the browser client.

When you are ready to build your own app, follow the installation guide and channel guide.