No description
  • Gleam 79.4%
  • JavaScript 20.6%
Find a file
2026-10-03 09:47:28 +01:00
.github 🔧 Update gleam version. 2026-07-14 01:13:30 +02:00
birdie_snapshots ⚡ Flatten nested patches for changes at only leaf nodes. (#462) 2026-04-18 19:18:20 +01:00
dev ♻️ Remove now-unused error type. 2026-01-09 20:06:48 +01:00
examples 📝 Add readmes to "view functions" and "keyed elements" examples. (#499) 2026-09-30 17:57:21 +01:00
pages 📝 Clarify that Lustre can render on the server in two different ways. 2026-09-30 17:50:09 +01:00
priv/static 🐛 Deeply clone style tags when adopting them in components. 2026-09-30 17:08:14 +01:00
src 📝 Document media html elements. 2026-10-02 22:03:19 +01:00
test ✨ Implement time travel for simulation apps. 2026-09-17 21:34:13 +01:00
.gitattributes 🔀 Add default_checked and default_selected attributes. (#371) 2025-11-01 13:36:33 +00:00
.gitignore 🙈 Ignore newer .lustre directory for dev-tools v2. 2025-10-25 10:35:04 +01:00
CHANGELOG.md 🔧 Bump minimum version for gleam_otp to 1.2.0 2026-10-03 09:47:28 +01:00
gleam.toml 🔧 Bump minimum version for gleam_otp to 1.2.0 2026-10-03 09:47:28 +01:00
LICENSE 📄 Add MIT license. 2022-05-21 09:42:24 +01:00
manifest.toml 🔧 Bump minimum version for gleam_otp to 1.2.0 2026-10-03 09:47:28 +01:00
README.md 📝 Remove stale references to inotify tools. 2026-09-30 17:02:46 +01:00

Lustre

✨ Make your frontend shine ✨
Create HTML templates, single page applications, Web Components, and real-time server components in Gleam!

Built with ❤︎ by Hayleigh Thompson and contributors

Table of contents

Features

  • A declarative, functional API for constructing HTML. No templates, no macros, just Gleam.

  • An Erlang and Elm-inspired architecture for managing state.

  • Managed side effects for predictable, testable code.

  • Universal components. Write once, run anywhere. Elm meets Phoenix LiveView.

  • A batteries-included CLI that makes scaffolding and building apps a breeze.

  • Server-side rendering for static HTML templating.

Example

Lustre comes with over 20 examples! Here's what it looks like:

import gleam/int
import lustre
import lustre/element.{text}
import lustre/element/html.{div, button, p}
import lustre/event.{on_click}

pub fn main() {
  let app = lustre.simple(init, update, view)
  let assert Ok(_) = lustre.start(app, "#app", Nil)

  Nil
}

fn init(_flags) {
  0
}

type Message {
  Incr
  Decr
}

fn update(model, message) {
  case message {
    Incr -> model + 1
    Decr -> model - 1
  }
}

fn view(model) {
  let count = int.to_string(model)

  div([], [
    button([on_click(Incr)], [text(" + ")]),
    p([], [text(count)]),
    button([on_click(Decr)], [text(" - ")])
  ])
}

Philosophy

Lustre is an opinionated library for building frontend Web applications. Modern frontend development is hard and complex. Some of that complexity is necessary, but a lot of it is accidental or comes from having far too many options. Lustre has the same design philosophy as Gleam: where possible, there should be only one way to do things!

That means shipping with a single state management system out of the box, modelled after Elm and Erlang/OTP. Open any Lustre application and you should feel right at home.

It also means we encourage simple approaches to constructing views over complex ones. Lustre does have a way to create encapsulated stateful components (something we sorely missed in Elm) but it shouldn't be the default. Prefer simple functions to stateful components.

Where components are necessary, lean into the fact that Lustre components can run anywhere. Lustre gives you the tools to write components that can run inside an existing Lustre application, export them as a standalone Web Component, or run them on the server with a minimal runtime for patching the DOM. Lustre calls these universal components and they're written with Gleam's multiple targets in mind.

Installation

Lustre is published on Hex! You can add it to your Gleam projects from the command line:

gleam add lustre

Lustre also has a companion package containing development tooling that you might like to install:

gleam add --dev lustre_dev_tools

Where next

To get up to speed with Lustre, check out the quickstart guide. If you prefer to see some code, the examples directory contains a handful of small applications that demonstrate different aspects of the library.

You can also read through the documentation and API reference on HexDocs.

Support

Lustre is mostly built by just me, Hayleigh, around two jobs. If you'd like to support my work, you can sponsor me on GitHub.

Contributions are also very welcome! If you've spotted a bug, or would like to suggest a feature, please open an issue or a pull request.