Skip to content

Latest commit

 

History

History
31 lines (24 loc) · 1.67 KB

README.md

File metadata and controls

31 lines (24 loc) · 1.67 KB

Elm SSR Experiments

Experiment in building an SSR app in Elm.

The server is heavily inspired by spades, but adds some new stuff (basically most of the TODO :-)). The way of breaking into the runtime is heavily inspired by elm-hot - I wouldn't be brave enough to try without elm-hot leading the way.

Running the server

You need to have Elm 0.19 already installed, then it's just:

$ yarn install
$ yarn run server

TODO:

  • Render a simple view
  • Keep focus after rehydration (but see Limitations)
  • Keep inputs state after rehydration
  • Rehydrate the state from the server
  • Handle functions in model (kind of)
  • Download data on the server / wait for a stable state
  • Integrate with parcel-plugin-elm-hot
  • Test with --optimize and --debug (optimize works, debug is broken)
  • Check that the model matches the bundle before rehydration
  • The Flick - the screen flicks when hydrating (worked around, solution will need a fix for elm/virtual-dom#144)

Limitations:

Those are left out of the demo on purpose, mostly because of difficulties with Elm 0.19 output:

  • Only works well with Browser.element - document and application remove existing DOM before attaching.
  • Only top-level, named functions can be serialized - using a closure or anonymous function will cause a failure on the server.
  • debugger doesn't work with SSR - the debugger keeps some unserializable state (like the sendToApp function). It can still be used on a mangled bundle without SSR.