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!

01-basics

These examples cover the fundamentals of Lustre such as setting up an application or rendering elements that can handle events.

02-inputs

Handling inputs and interactive elements is an important part of any application! These examples cover how to work with user input within the Model-View-Update architecture.

03-effects

These examples demonstrate how to handle side effects in Lustre applications. Side effects are actions that read from or affect change to the outside world, such as making HTTP requests, manipulating the DOM, or working with timers.

04-applications

Examples related to building full Lustre single-page applications (SPAs), covering concepts like routing, page organisation, and state hydration.

05-components

These examples demonstrate how to create reusable components in Lustre. Components are an advanced feature that let you construct real Custom Elements that have access to native features like shadow DOM, slotted content, and custom attributes and events.

06-server-components

Lustre components can also be run in real-time on the server, allowing you to take a part of your application and move it closer to the data source. These examples demonstrate Lustre’s server components.

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.

While our docs are still a work in progress, the official Elm guide is also a great resource for learning about the Model-View-Update architecture and the kinds of patterns that Lustre is built around.

Search Document