Skip to content

An Elm-inspired framework for building single page applications and server-rendered components in Gleam!

License

Notifications You must be signed in to change notification settings

deviant-forks/lustre

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Lustre

Package Version

An Elm-inspired framework for building web apps in Gleam!

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, "[data-lustre-app]", Nil)

  Nil
}

fn init(_) {
  0
}

type Msg {
  Incr
  Decr
}

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

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

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

Documentation

You can find the official documentation over at lustre.build. Note that if you're viewing the documentation published on Hexdocs, you may find that things are missing! Because of the way Gleam's documentation is generated, packages and functions that target only JavaScript don't get documented.

Installation

Lustre is available on Hex. You can install it like any other Hex package:

$ gleam add lustre

About

An Elm-inspired framework for building single page applications and server-rendered components in Gleam!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Gleam 61.0%
  • JavaScript 37.0%
  • Erlang 2.0%