rethinkdb / horizon

Horizon is a realtime, open-source backend for JavaScript apps.
MIT License
6.78k stars 351 forks source link

Server side rendering? #249

Open tslocke opened 8 years ago

tslocke commented 8 years ago

Unless I've missed something, the initial page load for a Horizon app goes through the typical "heavy" single-page-app startup process:

This is slow enough that front-end frameworks have moved to support pre-rendering on the server.

The difference can be dramatic - from several seconds down to a couple hundred milliseconds - and initial page load is well known to have a big impact on users.

Given Horizon's server side extensibility, I'm sure this is possible already, but I would argue it's important enough to make it super easy. For example, in react-rails, it's as easy as

<%= react_component('SomeComponent', {}, {prerender: true}) %>
deontologician commented 8 years ago

This is something I think we'd like to do long term, but, as you mentioned, we aren't talking with the view layer, and I think it'd be good to keep it that way. So we'll need to come up with a "Horizon-y" way of doing this so everybody will be able to get these features, not just React people etc.

That being said, you can of course write your own backend and do server side rendering there, so it's definitely doable. I think it would be nice if we had a middle ground between frontend-only apps, and "now you have to write a backend and import horizon" apps. That's a big gap to jump for just server side rendering

alterx commented 8 years ago

I think that this feature should be a standalone module, then you can just create your own nodejs backend that requires this module and horizon and do your magic there. It just feels like this shouldn't belong to horizon's core.