Meteor.js : Working with routes

As we all know that meteor can only be used to create a single page web apps. Still there are many instances when one want to work with different URL’s on a web applications.

This problem in Meteor is solved by using routes. Whenever a user does some event(mostly tries to click on a link) on the website then we can create a route to different templates and open them on the client side creating a great user experience.

Now there are a lot packages available in the meteor for handling these routes. The two of them which are most famous are :

  • Iron router
  • Flow router

Both of them are great but I am going to use Flow router for my further learning process.

Flow router is created by a team at kadira: flow router. We can add this router to our application by using this command while we are in the meteor app root directory.

$ meteor add kadira:flow-router

Now run your app using the basic meteor command to run the app

$ meteor

This will run the app on localhost:3000. Now in the browser you can go to different routes to check this small example about the routes.

As the routes are very basic to client we can put them in the client folder present in the application but it is recommended that we must put them in the /lib folder inside the root folder. So first of all create a folder named lib when inside root folder of the app.

Now create a document with the name of routes.js. We are going to put all our routes in there. Here I am going to discuss the very basic example so that we can see whats happening. We can further extend our work from there on.

In the file write this content.

FlowRouter.route( '/home', {
  action: function() {
    console.log( "Welcome to the homepage" );
  name: 'Home'

This type of route is known as static route which is used to create route for a static address. For example if we want to create a page for home we can create by using this type of route. Now go to http://localhost:3000/home and opening the browser console we can see the comment : “welcome to the homepage” (without quotes).

There is more to routers which I will talk in the upcoming post.

If something not correct in the post please comment below. If still confused feel free to contact using the comments.

Meteors : The full stack JavaScript framework



So, first framework that I came across was Meteor.js

Meteor.js is the full stack framework which make use of the whole stack and implements it in a better and a simple way.

Some of the feature of meteor.js are :-

1. It is a very mature framework with a lot of facilities.
2. Server side and client code is same.
3. Server side code is based on Node.js So, no need to learn any other language.
4. Fb, google authentication is already available.
5. Deployment of the app is very easy. After making the app you can deploy it on
6. Documentation is great and is easy to learn.
7. Android or ios app can be made.

There are also many times when you don’t want to use Meteor. for example:-

1. When you want to build a website and not a app which you want to work on allmost every device.

2. If you want a app in which you want lesser server interaction because this technology uses a lot of the space in the RAM making the system slower.


So, you should start a project in meteor.js . You can work in this framework if you have some prior knowledge of HTML, CSS and JavaScript. If you have that then its the time to get your hands dirty by writing some of the syntax in the language.


Ranvir Singh