kadirahq / flow-router

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

SSR Support WIthin Meteor's Preferred Application Structure #591

Open joncursi opened 8 years ago

joncursi commented 8 years ago

Meteor recommends a particular structure when structuring your application, which places routes.js inside the imports directory and all components within a ui directory. See http://guide.meteor.com/structure.html#example-app-structure

This structure seems to break flow router's SSR support, which requires that these files be available on both the client and server in a lib or app directory. It is possible to have SSR support without changing Meteor's preferred app structure? Thanks!

klarstrup commented 8 years ago

I'm using that structure and getting ssr - the only difference is importing the applicable client stuff (ie routes) in the server startup file

On Sat, Apr 9, 2016, 11:45 Jon Cursi notifications@github.com wrote:

Meteor recommends a particular structure when structuring your application, which places routes.js inside the imports directory and all components within a ui directory. This seems to break flow router's SSR support, which requires that these files be available on both the client and server.

It is possible to have SSR support without changing Meteor's preferred app structure? Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/kadirahq/flow-router/issues/591

dovrosenberg commented 8 years ago

@joncursi - I think the trick is (unlike the todos sample) to not import the templates in routes.js. Then you can include routes.js on both the client and server side. I created a startup/both directory and put it there with other things that would have been in lib in the old structure. I then include those files on both the client and server. On the client, then, you have to remember to import the template routes that you took out of routes.js somewhere else.

matthlavacka commented 8 years ago

I maintained Meteor 1.3 structure, but have startup/both/routes.jsx that I import to both startup/client and startup/server. Not sure if best practise, but it does the job.

frankapimenta commented 8 years ago

I think that routes for server side render must be defined in both client and server. The others can be defined only in client.