kadirahq / flow-router

Carefully Designed Client Side Router for Meteor
MIT License
1.09k stars 194 forks source link

SSR with Blaze #545

Open mitar opened 8 years ago

mitar commented 8 years ago

Blaze is not available on the server side, but Blaze Components are. I have not done much testing with SSR, but I am opening ticket here if anyone is interested to try to implement it.

(Just to be clear, if you use Blaze Components, you can also use pure Blaze, so using Blaze Components instead of Blaze gives you also normal Blaze support on the server side. So this can work even for simple Blaze templates.)

See related ticket in Blaze Components repository: https://github.com/peerlibrary/meteor-blaze-components/issues/110

arunoda commented 8 years ago

Okay. If so, I think this is super cool. This is how to add the support for SSR.

Make sure BlazeComponents are rendered inside a FlowRouter action. In the client, do it normally. In the server, generate the HTML and send it to FlowRouter like this:

See: https://github.com/kadirahq/react-mounter/blob/master/lib/server.js#L26

mitar commented 8 years ago

What about wrapping subscribe calls inside Blaze Components? Will this be done automatically?

arunoda commented 8 years ago

Yes. They are automatic. But they need to happen in the same eventloop cycle where FlowRouter .action() is called.

Using it inside a Tracker.autorun is fine.

mkpazon commented 8 years ago

+1

brown2rl commented 8 years ago

I would like to contribute. Is anyone actively doing this? Seems like the guide dropped iron router

mitar commented 8 years ago

See some discussion here and related tickets.