Iron Router is seriously awesome and simple to use

I know FlowRouter is the popular choice, probably because it is specifically mentioned in the docs, but I do hope more people (especially those that are new in Meteor, in 2020 btw) consider using Iron Router and Blaze in their new projects as well.

I myself am just returning to Meteor after I first heard it, and back then I was still a junior dev, so I mostly opted to use easy to understand tools for development because I was the only web developer at that time from where I was working (looked for mentors, found none, thank the heavens for internet).

I spent way more time reading docs of various routers in Meteor (analysis paralysis sucks), and I seriously thought Iron Router has the best documentation. It’s both clear and shows code samples that are easy to understand.

And it supports what I’m looking for now, a way to have client routes and server side routes (I need to have REST endpoints for external applications).

At first I thought about using FlowRouter and webapp + express, then I thought, “hey why am I making things complicated for me?”. So I went with Iron Router instead.

I now believe it stood the test of time. This post was inspired by @vlasky from his reply here.

Before, I was constantly looking at the “next shiny thing”. I tried React, didn’t work for me, I’m not as smart as most people who uses it, and certainly not advanced (maybe after 2yrs, after I finish YDKJS) in JS enough to make efficient use of it. Later on I found Vue and was extremely happy with it. Then I got a good combo using NuxtJs and AdonisJs.

But when I heard Meteor got a new family in Tiny, I went back and took another look, and am now deciding to stay for as long as I can.

I am now (hopefully lol) not easily swayed by FUD (Fear, Uncertainty, Doubt) posts, most of them are because it’s easy to fall into architecture pitfalls anyway (which can be solved by refactoring your code using best practices, which Blaze has in here).

I hope this post encourages new comers to Meteor to still consider trying Blaze and Iron Router.

PS: One of the main reasons I took another look at Meteor also was this post.

Happy coding!

8 Likes

Any particular reason you recommend blaze?

Blaze is designed to work with Meteor. That’s one compelling reason.

I’ve found it to be well designed and relatively bug free. It’s not fashionable, but it’s a solid choice with Meteor. The biggest downside is that you need to ship jQuery with Blaze.

4 Likes

My biggest issue with IronRouter currently is that it seems to be unmaintained:


Screen Shot 2020-03-03 at 2.24.13 PM

I guess you could argue “why mess with perfection” :slightly_smiling_face: – but still, even things like updating which version of jQuery it depends on would be really great to have after 3 years. I’d be nervous about introducing it into a new project unless it’s picked up by someone in the community.

1 Like

As what @arggh said, Blaze is designed to work with Meteor, that’s why I’m opting to use it.
I didn’t consider React because I couldn’t justify it’s steep learning curve for my other team mates, and I personally didn’t like JSX (I hate writing html in strings or even inside JS files). And then there’s Vue, which is faster than React (according to some claims), and significantly easier to learn.

Here is my short stint with React, this is not whining, just what I said on my post, that I’m not smart enough (yet) for it. When I tried React, even after a month of reading and watching videos, when I started coding I still found my self constantly going back to the docs (and google) for what I was trying to do. Also, it didn’t force me to write better code, I know that’s just my problem, but after coding with React for a while, I couldn’t even follow my own code at a glance after just two weeks of not looking into it. I didn’t experience that with Vue, hence I’m saying Vue is easier to learn. It took me just two weeks to be productive with it, and I don’t get lost every time I looked back on my code after not seeing it for a while lol.

Going back to your question, I did look at meteor-vue, but somehow didn’t see the point of using it especially when Blaze can do everything it does already, when you read here. I’m probably just missing NuxtJS whenever I see Vue in other places lol (admittedly, it spoiled me a lot), that’s why I’m structuring my folders in Nuxt’s pattern.

Also, I frequently found myself creating components that can’t live without its parent, and I needed Blaze’s ability to automatically inherit context, instead of writing a bunch of function to communicate between the two.

If I had to rate the UI libraries according to my own mileage, I’d say:

  1. Vue
  2. Blaze
  3. React

But for Meteor, I’m picking Blaze because, well, it’s made for it, and I found in some places here in the forum that if Meteor upgrade introduces breaking changes, they themselves will fix Blaze.

I suggest you choose what your willing to stick to for a long time. Sorry for the long reply, cheers! :beers:

2 Likes

No arguments here bro, when I started with Meteor, I skipped IronRouter just because of that, didn’t even bother looking at the docs. I used FlowRouter right away, even though I had a hard time starting with it for a while (I really need to brush up my skills lol).

But like I said, I needed Client and Server side routes, and when I looked for other ways to whip up server routes, it got me to many places, which gave me headaches.

That’s when I considered looking at Iron Router, I thought to myself, “hey Iron Router says its both Client and Server routes, maybe I should take a look, and having one library to handle both routes might be a good idea”. When I saw the docs, it actually impressed me because I find it not only concise and somewhat complete, but also it’s beautiful enough not to be an eye sore. It’s organized as well.

Then I found out people are actually using it until now for large apps with relatively high demand that has business around it (@vlasky to name one). That’s what convinced me to use it because, if ever a problem pops up with Iron Router, I know people will jump in and fix it (hopefully I can help too).

And the fact that nothing major broke it yet, for me, is a major feat.

For the jquery issue, you can look here.
I’m using it with the latest jquery from npm, no issues yet.
Even Meteor is using the latest jquery now.

  1. Open .meteor/packages
  2. add “@3.0.0!” to jquery, without the quoutes (jquery@3.0.0!)
  3. Install Iron Router as usual (meteor add iron:router)

This will tell meteor to skip the packaged jquery and use the one from npm, and tell other meteor packages to ignore their version specific jquery dependency (which is usually version 1.x.x).

To clarify, my team also uses Iron Router in a production application with high usage, so I’m speaking from experience! It works really well for its purpose. But, despite that, I would be hesitant to recommend it for those starting new projects because of the fact that it’s not actively maintained – yes, you can work around things like outdated jQuery version, but that’s just one symptom of the larger issue of the Iron Router package not receiving updates. On the client side, there are other options (without even getting into the Blaze vs. React vs. the field argument), and on the server-side, it’s not hard to route using WebApp.

None of that is meant to invalidate your excitement or enthusiasm, just adding a disclaimer for others reading the forums and considering routers to use in their own projects. I’m glad you’ve found success with your stack, and perhaps you’ll even become the maintainer that the Iron Router project needs in the future! :rocket:

5 Likes

I wholeheartedly agree.
Most of my Meteor projects have small audiences and are around art installations and performances so aren’t deployed for very long. I appreciate how easy to use Iron Router and Blaze are.
I love Meteor!

Sorry to be a bit offtopic, but:

this is a common misconception about React. No, you don’t write html inside js files. You write nested functions. JSX is syntactic sugar. Take React-Native: you don’t have html there. Still same concept.

Many other frontend framework invent some kind of extended html template language (e.g. handlebars from blaze). I think that is the hack. React manages to do it with pure javascript and only adds optional syntactic sugar to help with a common pattern.

Concerning ironrouter: yes, its easy to use together with blaze. But blaze und ironrouter are unmaintained. If you work in a team, i would carefully evaluate if I would use blaze and ironrouter these days. For smaller projects: go with it.

1 Like

Just to expand here:

<div>Whatever</div>

In jsx isn’t html. It compiles to

React.createElement("div", null, "Whatever");

You can technically write react by doing that directly, but no one does because that would be silly.

Anyway, I wasn’t asking why you were using blaze because I thought react was a better options - I genuinely wanted to know what you liked about blaze.

You can play with that jsx transformation here: https://babeljs.io/repl/#?browsers=&build=&builtIns=false&spec=false&loose=false&code_lz=DwEwlgbgfA6gFgQwC4FMIoE7APTmkA&debug=false&forceAllTransforms=false&shippedProposals=false&circleciRepo=&evaluate=false&fileSize=false&timeTravel=false&sourceType=module&lineWrap=true&presets=es2015%2Creact%2Cstage-2&prettier=false&targets=&version=7.8.7&externalPlugins=

True. I don’t know why flow router or react. None of the major front frameworks look native to me. I’m waiting for the new framework.

React just makes simple things so complicated. More difficult to understand when you have many lines of code for a simple functionality. That said, I’ll probably move to vue though I’m not very satisfied with it

1 Like

Iron router works just fine. We’ve had a project running on it for the past 5-6 years.
We would have moved to Flow Router but just never got round to it. Our codebase is a mix of Blaze and React.
Today we’d choose React Router without Blaze.

I use the awesome iron:router package in all my Meteor projects. One problem I run into in almost all packages is if you use Router.go() while scrolled down onto the page, your next page will rendered still scrolled at the same point.

I don’t use iron:router, but I’m betting it has the required hooks for setting up a function to reset scroll position on navigation (when necessary). Or you can do it from the parent component of each view. A router cannot assume you want to scroll the view to the top on every navigation event.

1 Like