Lustre examples directory
Each of the examples in this directory is a self-contained, complete Gleam app that demonstrates a particular feature or concept of the library. For newcomers, we recommend looking through them in order, as each example tends to build on the previous ones. Feel free to jump in to any example that interests you, though!
Note: these examples all use
lustre/uito show off something a little more visually interesting than unstyled HTML. None of the ideas in these examples are specific tolustre/ui, though, and you should know that you can follow along with any of these examples using only the standardlustre/element/htmlmodule.
Examples
-
01-hello-worldis a simple example to just get something on the screen. -
02-interactivityintroduces the core Model-View-Update loop that underpins every Lustre application. -
03-controlled-inputsdemonstrates the most common way to handle<input />elements in Lustre. -
04-custom-event-handlersshows you how to write your own event handlers and decoders, instead of relying on the ones provided bylustre/event. -
05-http-requestsdemonstrates how side effects are handled in Lustre, using the third-partylustre_httppackage. -
06-custom-effectsbuilds on the previous example and shows you how to write your own side effects for Lustre to perform. -
07-routingshows how to usemodemto set up routing and navigating between pages in a Lustre app.
Getting help
If you’re having trouble with Lustre or not sure what the right way to do something is, the best place to get help is the Gleam Discord server. You could also open an issue on the Lustre GitHub repository.