lustre-labs / lustre

A Gleam web framework for building HTML templates, single page applications, and real-time server components.
https://hexdocs.pm/lustre
MIT License
950 stars 65 forks source link

✨ Serve `main` functions that return Lustre elements with `lustre/try`. #28

Closed hayleigh-dot-dev closed 7 months ago

hayleigh-dot-dev commented 9 months ago

The lustre/try preview server only expects full Lustre applications to be defined by an app's main function. For the folks super new to Lustre and frontend development in general, even that might be a little too high of a barrier.

We should also support the scenario where they return just a simple Element, such as:

pub fn main() {
  html.h1([], [
    element.text("Hello, world!")
  ])
}

So they can get something on the page ASAP.