facebookarchive / react-meteor

React rendering for Meteor apps
948 stars 113 forks source link

Feature Request: Server Side Rendering #41

Open IstoraMandiri opened 9 years ago

IstoraMandiri commented 9 years ago

As we all know Meteor currently suffers from a problem with SEO due to the initial payload not containing any actual html templates.

Giving that react supports SSR (Server Side Rendering) thanks to the Virtual DOM, I think this would be an absolutely killer feature for most meteor apps, and I would love to spend some energy figuring out if this is possible.

It's probably quite a complex job, but let's open up the floor to ideas and approaches! I'm sure some of those reading this know more about the obstacles than I.

My first thought is to use inject-initial and/or iron-router to send pre-rendered templates if a user lands on a particular route. We'd need to get the client session and render out the route with the relevant subscriptions. I would imagine there would then be some intricacies for handing rendering over to the client for subsequent reactivity.

Anyway, anyone think this is is possible or worth looking into?

hellogerard commented 9 years ago

If you look at the pull requests, You'll find a reference to another repo that has a server-side-rendering proof-of-concept. Percolate just blogged about this repo too. Unfortunately, it takes a custom fork of meteor to work.

There's another meteor package called meteor-routecore. It's got server-side rendering working on a basic level already. Surprised it's not mentioned more. Unfortunately, not sure how well it's maintained.

arunoda commented 9 years ago

I got some idea. Let's see, I've some ideas. Fast Render has solved a lot of issues. Let me see, whether I can hook this with Flow Router.

IstoraMandiri commented 9 years ago

Reassuring to hear you're on the case @arunoda!

@hellogerard - https://github.com/percolatestudio/react-leaderboard this one? Here's a related PR https://github.com/meteor/meteor/pull/3860.

Demo here http://react-leaderboard-by-percolatestudio.meteor.com/

Btw, percolate's POC depends on this very repo.

dmitry commented 9 years ago

@hitchcott looks like it loads data on the client side after javascript is loaded, because I can see rendering update. Is it possible to sync server loaded data and client data?

PS. Looks like this package should fix that issue: https://github.com/meteorhacks/fast-render