alexmingoia / pux-starter-app

Starter Pux app w/ hot-reloading and isomorphic routing and rendering
https://www.purescript-pux.org
BSD 3-Clause "New" or "Revised" License
101 stars 39 forks source link

Server-side pre-rendering: I do not understand how it currently works with Pux #27

Closed cies closed 7 years ago

cies commented 7 years ago

First: thanks for making Pux, it is an amazingly complete and useful piece of machinery.

In the issues I found that server-side rendering should be implemented, but I do not see how that works. Also I think that to do pre-rendering of the kind that I found very useful in React apps, it needs to be able to parse the routes on the server-side, in order to know how to pre-render the right page.

Currently it uses a middleware to catch any routes and serve the index.html, then the actual rendering takes place on the client.

Now if the routing code can be used server-side (possibly combined with a cookie) to pre-render the page that would otherwise get rendered on the client, and serve that instead of the index.html: that would be the useful kind of pre-rendering I've come to like from using React.

I'm not aware of any framework in a strongly typed language that compiles to JS (PureScript/ Elm/ GHCJS) that can do this trick.

The benefits of doing this kind of pre-rendering are:

alexmingoia commented 7 years ago

With the Pux 8 release, the starter app now has a full isomorphic routing and rendering configuration.

Check it out and let me know if you have more questions about how it works.

cies commented 7 years ago

Wow and thanks! I'll have a look.