I raised this on Slack. Moving the conversation here, since regardless of the outcome I suspect there is value in capturing ideas in a place where they can be referenced in the future.
In the local JavaScript community here in Melbourne, Australia, the #1 thing that people cite as a reason for holding off exploring Elm in my conversations with them is lack of support for server-side rendering. If the focus of the core development team is on other important things right now, I wonder if there is room for an elm-explorations initiative to establish a community-supported model for rendering Elm views on the server and then having that pre-rendered HTML DOM “adopted” (or “hydrated”) by the Elm runtime in the browser.
Note: Static server-side rendering (generating a non-interactive web page from Elm views on the server) is a simpler problem. I’m told elm-pages does this very well, which is great. But a lot of potential Elm adopters really need their interactive Elm app to be able to serve its initial view pre-rendered by the server, and then have it become interactive on the client-side.
Reasons for wanting this:
- Time to first paint (which impacts SEO)
- Accessibility with JavaScript disabled (which impacts SEO, especially on non-Google search engines)
The problem is not a trivial one to solve. Knowing at what point an Elm application has “settled” (e.g. fetched any data required to render a useful initial state), and is ready to be sent to the client, and also capturing that server-side state and attaching it (and the server-rendered HTML DOM) to the client-side runtime are both tricky things to do well. Elm’s immutable data design makes it perhaps uniquely suited to doing this reliably, however!
I believe there have been some experiments done with SSR for Elm by others, and I’d love to collect some links to those on this thread, as well as brief summaries of what those experiments were able to achieve (and perhaps what they weren’t). If it should happen that a 90% solution is already out there and it just needs some community support around it in the form of documentation, blogging, conference talks, etc., I’d be very excited to help out with that (rather than with code, which we all know is the easy part).
A couple of previous threads on this topic:
Explorations in Server Side Rendering
Server-side rendering in Elm 0.19