4

I am asking this question because I am a bit confused. I just started to discover meteor ( better late then never ) and I am reading/hearing a lot of discussions why I should use Flow-router instead of Iron router.

I started my project with Iron router, but the more I read the more I think I should switch to Flow-router for many performances, rendering reasons ...

What pro's and con's make them different?

Sank U !

TheBilTheory
  • 408
  • 2
  • 12

4 Answers4

2

The official documentation recommends FlowRouter: https://guide.meteor.com/routing.html

But you can use iron router too. I have already used them both in different projects, but I decided to follow meteor official recommendation.

  • I guess FlowRouter does not do server side routing, though. Is that correct? – nroose Apr 21 '18 at 23:43
  • Correct, which sucks if you're building ANY api features in your app. I am currently reverting back to Iron... sigh.. – Andy Jul 27 '18 at 19:13
  • I find it better to have the router only deal with the client-side routing logic. For server-side API routing I use the [webapp](https://docs.meteor.com/packages/webapp.html) package (with a combination of other tools on top). – Valeriu Paloş Jul 05 '19 at 18:28
1

I use IronRouter, because the description states that

"FlowRouter only deals with registration of subscriptions. It does not wait until subscription becomes ready."

(https://github.com/kadirahq/flow-router) Because of this, when you subscribe to large data, you get extra page updates or failures. So I chosed IronRouter, which in the documentation describes how to make the waiting for the subscription ready (WaitOn). It works without problems 2 years for me. From the point of view of the update, both routers have not been updated for a long time, more than a year, so it is unclear whether the revision is coming as new versions of Meteor are released.

  • Please use the much improved [flow-router-extra package](https://atmospherejs.com/ostrio/flow-router-extra) which definitely waits for the subscription to become ready (i.e. the first data batch to be available on the client) before continuing to the route's `action()` function. – Valeriu Paloş Jul 05 '19 at 18:25
0

Press F12 in browser, watch for any errors. In my case I removed a package, but did not remove the code calling that package.

It errored, and looked like Iron Router was to blame.

Removed the offending code loading some other lib I removed and hey, Iron Router works.

Andy
  • 966
  • 11
  • 16
0

The problem with FlowRotuer is you have to jump through hoops to load data into a template.

It makes code complex, fragmented and hard to follow (My opinion).

Iron Router allows you to pass data in as a second argument to the render function and access it directly from the template.

With Flow Router you have to first write data to a session, then write a Template helper to pull the session data or wrap your template in a "with" element.

This is an example how FlowRouter would have you get some example into a template

Template.templateName.onCreated(function() {
   Meteor.call('thirdPartyAPI', function(error, result) {
      Session.set('result', result);
   });
});

Then on the template side you could have:

{{#with result}}
   Content that requires a context
{{/with}}

And you would have a template helper that returned the Session/ReactiveVar, e.g.

Template.templateName.helpers({
  result: function() {
    return Session.get('result');
  }
});

A similar example with Iron Router

Router.route('/post/:_id', function () {
  this.render('Post', {
    data: function () {
      return Posts.findOne({_id: this.params._id});
    }
  });
});
PrestonDocks
  • 4,851
  • 9
  • 47
  • 82