{"id":13602795,"url":"https://github.com/kadirahq/flow-router","last_synced_at":"2025-12-16T17:42:49.410Z","repository":{"id":24359404,"uuid":"27758092","full_name":"kadirahq/flow-router","owner":"kadirahq","description":"Carefully Designed Client Side Router for Meteor","archived":false,"fork":false,"pushed_at":"2022-06-22T09:38:41.000Z","size":651,"stargazers_count":1083,"open_issues_count":177,"forks_count":197,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-05-07T17:05:32.585Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kadirahq.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-12-09T09:01:50.000Z","updated_at":"2025-02-28T14:39:01.000Z","dependencies_parsed_at":"2022-09-03T01:05:24.027Z","dependency_job_id":null,"html_url":"https://github.com/kadirahq/flow-router","commit_stats":null,"previous_names":[],"tags_count":80,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kadirahq%2Fflow-router","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kadirahq%2Fflow-router/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kadirahq%2Fflow-router/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kadirahq%2Fflow-router/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kadirahq","download_url":"https://codeload.github.com/kadirahq/flow-router/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478186,"owners_count":22077675,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T18:01:38.280Z","updated_at":"2025-12-16T17:42:44.372Z","avatar_url":"https://github.com/kadirahq.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# FlowRouter [![Build Status](https://travis-ci.org/kadirahq/flow-router.svg?branch=master)](https://travis-ci.org/kadirahq/flow-router) [![Stories in Ready](https://badge.waffle.io/kadirahq/flow-router.svg?label=doing\u0026title=Activities)](http://waffle.io/kadirahq/flow-router)\n\n\nCarefully Designed Client Side Router for Meteor.\n\nFlowRouter is a very simple router for Meteor. It does routing for client-side apps and does not handle rendering itself.\n\nIt exposes a great API for changing the URL and reactively getting data from the URL. However, inside the router, it's not reactive. Most importantly, FlowRouter is designed with performance in mind and it focuses on what it does best: **routing**.\n\n\u003e We've released 2.0 and follow this [migration guide](#migrating-into-20) if you are already using FlowRouter.\n\n## TOC\n\n* [Meteor Routing Guide](#meteor-routing-guide)\n* [Getting Started](#getting-started)\n* [Routes Definition](#routes-definition)\n* [Group Routes](#group-routes)\n* [Rendering and Layout Management](#rendering-and-layout-management)\n* [Triggers](#triggers)\n* [Not Found Routes](#not-found-routes)\n* [API](#api)\n* [Subscription Management](#subscription-management)\n* [IE9 Support](#ie9-support)\n* [Hashbang URLs](#hashbang-urls)\n* [Prefixed paths](#prefixed-paths)\n* [Add-ons](#add-ons)\n* [Difference with Iron Router](#difference-with-iron-router)\n* [Migrating into 2.0](#migrating-into-20)\n\n## Meteor Routing Guide\n\n[Meteor Routing Guide](https://kadira.io/academy/meteor-routing-guide) is a completed guide into **routing** and related topics in Meteor. It talks about how to use FlowRouter properly and use it with **Blaze and React**. It also shows how to manage **subscriptions** and implement **auth logic** in the view layer.\n\n[![Meteor Routing Guide](https://cldup.com/AxlPfoxXmR.png)](https://kadira.io/academy/meteor-routing-guide)\n\n## Getting Started\n\nAdd FlowRouter to your app:\n\n~~~shell\nmeteor add kadira:flow-router\n~~~\n\nLet's write our first route (add this file to `lib/router.js`):\n\n~~~js\nFlowRouter.route('/blog/:postId', {\n    action: function(params, queryParams) {\n        console.log(\"Yeah! We are on the post:\", params.postId);\n    }\n});\n~~~\n\nThen visit `/blog/my-post-id` from the browser or invoke the following command from the browser console:\n\n~~~js\nFlowRouter.go('/blog/my-post-id');\n~~~\n\nThen you can see some messages printed in the console.\n\n## Routes Definition\n\nFlowRouter routes are very simple and based on the syntax of [path-to-regexp](https://github.com/pillarjs/path-to-regexp) which is used in both [Express](http://expressjs.com/) and `iron:router`.\n\nHere's the syntax for a simple route:\n\n~~~js\nFlowRouter.route('/blog/:postId', {\n    // do some action for this route\n    action: function(params, queryParams) {\n        console.log(\"Params:\", params);\n        console.log(\"Query Params:\", queryParams);\n    },\n\n    name: \"\u003cname for the route\u003e\" // optional\n});\n~~~\n\nSo, this route will be activated when you visit a url like below:\n\n~~~js\nFlowRouter.go('/blog/my-post?comments=on\u0026color=dark');\n~~~\n\nAfter you've visit the route, this will be printed in the console:\n\n~~~\nParams: {postId: \"my-post\"}\nQuery Params: {comments: \"on\", color: \"dark\"}\n~~~\n\nFor a single interaction, the router only runs once. That means, after you've visit a route, first it will call `triggers`, then `subscriptions` and finally `action`. After that happens, none of those methods will be called again for that route visit.\n\nYou can define routes anywhere in the `client` directory. But, we recommend to add them in the `lib` directory. Then `fast-render` can detect subscriptions and send them for you (we'll talk about this is a moment).\n\n### Group Routes\n\nYou can group routes for better route organization. Here's an example:\n\n~~~js\nvar adminRoutes = FlowRouter.group({\n  prefix: '/admin',\n  name: 'admin',\n  triggersEnter: [function(context, redirect) {\n    console.log('running group triggers');\n  }]\n});\n\n// handling /admin route\nadminRoutes.route('/', {\n  action: function() {\n    BlazeLayout.render('componentLayout', {content: 'admin'});\n  },\n  triggersEnter: [function(context, redirect) {\n    console.log('running /admin trigger');\n  }]\n});\n\n// handling /admin/posts\nadminRoutes.route('/posts', {\n  action: function() {\n    BlazeLayout.render('componentLayout', {content: 'posts'});\n  }\n});\n~~~\n\n**All of the options for the `FlowRouter.group()` are optional.**\n\nYou can even have nested group routes as shown below:\n\n~~~js\nvar adminRoutes = FlowRouter.group({\n    prefix: \"/admin\",\n    name: \"admin\"\n});\n\nvar superAdminRoutes = adminRoutes.group({\n    prefix: \"/super\",\n    name: \"superadmin\"\n});\n\n// handling /admin/super/post\nsuperAdminRoutes.route('/post', {\n    action: function() {\n\n    }\n});\n~~~\n\nYou can determine which group the current route is in using:\n\n~~~js\nFlowRouter.current().route.group.name\n~~~\n\nThis can be useful for determining if the current route is in a specific group (e.g. *admin*, *public*, *loggedIn*) without needing to use prefixes if you don't want to. If it's a nested group, you can get the parent group's name with:\n\n~~~js\nFlowRouter.current().route.group.parent.name\n~~~\n\nAs with all current route properties, these are not reactive, but can be combined with `FlowRouter.watchPathChange()` to get group names reactively.\n\n## Rendering and Layout Management\n\nFlowRouter does not handle rendering or layout management. For that, you can use:\n\n  * [Blaze Layout for Blaze](https://github.com/kadirahq/blaze-layout)\n  * [React Layout for React](https://github.com/kadirahq/meteor-react-layout)\n\nThen you can invoke the layout manager inside the `action` method in the router.\n\n~~~js\nFlowRouter.route('/blog/:postId', {\n    action: function(params) {\n        BlazeLayout.render(\"mainLayout\", {area: \"blog\"});\n    }\n});\n~~~\n\n## Triggers\n\nTriggers are the way FlowRouter allows you to perform tasks before you **enter** into a route and after you **exit** from a route.\n\n#### Defining triggers for a route\n\nHere's how you can define triggers for a route:\n\n~~~js\nFlowRouter.route('/home', {\n  // calls just before the action\n  triggersEnter: [trackRouteEntry],\n  action: function() {\n    // do something you like\n  },\n  // calls when we decide to move to another route\n  // but calls before the next route started\n  triggersExit: [trackRouteClose]\n});\n\nfunction trackRouteEntry(context) {\n  // context is the output of `FlowRouter.current()`\n  Mixpanel.track(\"visit-to-home\", context.queryParams);\n}\n\nfunction trackRouteClose(context) {\n  Mixpanel.track(\"move-from-home\", context.queryParams);\n}\n~~~\n\n#### Defining triggers for a group route\n\nThis is how you can define triggers on a group definition.\n\n~~~js\nvar adminRoutes = FlowRouter.group({\n  prefix: '/admin',\n  triggersEnter: [trackRouteEntry],\n  triggersExit: [trackRouteEntry]\n});\n~~~\n\n\u003e You can add triggers to individual routes in the group too.\n\n#### Defining Triggers Globally\n\nYou can also define triggers globally. Here's how to do it:\n\n~~~js\nFlowRouter.triggers.enter([cb1, cb2]);\nFlowRouter.triggers.exit([cb1, cb2]);\n\n// filtering\nFlowRouter.triggers.enter([trackRouteEntry], {only: [\"home\"]});\nFlowRouter.triggers.exit([trackRouteExit], {except: [\"home\"]});\n~~~\n\nAs you can see from the last two examples, you can filter routes using the `only` or `except` keywords. But, you can't use both `only` and `except` at once.\n\n\u003e If you'd like to learn more about triggers and design decisions, visit [here](https://github.com/meteorhacks/flow-router/pull/59).\n\n#### Redirecting With Triggers\n\nYou can redirect to a different route using triggers. You can do it from both enter and exit triggers. See how to do it:\n\n~~~js\nFlowRouter.route('/', {\n  triggersEnter: [function(context, redirect) {\n    redirect('/some-other-path');\n  }],\n  action: function(_params) {\n    throw new Error(\"this should not get called\");\n  }\n});\n~~~\n\nEvery trigger callback comes with a second argument: a function you can use to redirect to a different route. Redirect also has few properties to make sure it's not blocking the router.\n\n* redirect must be called with an URL\n* redirect must be called within the same event loop cycle (no async or called inside a Tracker)\n* redirect cannot be called multiple times\n\nCheck this [PR](https://github.com/meteorhacks/flow-router/pull/172) to learn more about our redirect API.\n\n#### Stopping the Callback With Triggers\n\nIn some cases, you may need to stop the route callback from firing using triggers. You can do this in **before** triggers, using the third argument: the `stop` function. For example, you can check the prefix and if it fails, show the notFound layout and stop before the action fires.\n\n```js\nvar localeGroup = FlowRouter.group({\n  prefix: '/:locale?',\n  triggersEnter: [localeCheck]\n});\n\nlocaleGroup.route('/login', {\n  action: function (params, queryParams) {\n    BlazeLayout.render('componentLayout', {content: 'login'});\n  }\n});\n\nfunction localeCheck(context, redirect, stop) {\n  var locale = context.params.locale;\n\n  if (locale !== undefined \u0026\u0026 locale !== 'fr') {\n    BlazeLayout.render('notFound');\n    stop();\n  }\n}\n```\n\n\u003e **Note**: When using the stop function, you should always pass the second **redirect** argument, even if you won't use it.\n\n## Not Found Routes\n\nYou can configure Not Found routes like this:\n\n~~~js\nFlowRouter.notFound = {\n    // Subscriptions registered here don't have Fast Render support.\n    subscriptions: function() {\n\n    },\n    action: function() {\n\n    }\n};\n~~~\n\n## API\n\nFlowRouter has a rich API to help you to navigate the router and reactively get information from the router.\n\n#### FlowRouter.getParam(paramName);\n\nReactive function which you can use to get a parameter from the URL.\n\n~~~js\n// route def: /apps/:appId\n// url: /apps/this-is-my-app\n\nvar appId = FlowRouter.getParam(\"appId\");\nconsole.log(appId); // prints \"this-is-my-app\"\n~~~\n\n#### FlowRouter.getQueryParam(queryStringKey);\n\nReactive function which you can use to get a value from the queryString.\n\n~~~js\n// route def: /apps/:appId\n// url: /apps/this-is-my-app?show=yes\u0026color=red\n\nvar color = FlowRouter.getQueryParam(\"color\");\nconsole.log(color); // prints \"red\"\n~~~\n\n#### FlowRouter.path(pathDef, params, queryParams)\n\nGenerate a path from a path definition. Both `params` and `queryParams` are optional.\n\nSpecial characters in `params` and `queryParams` will be URL encoded.\n\n~~~js\nvar pathDef = \"/blog/:cat/:id\";\nvar params = {cat: \"met eor\", id: \"abc\"};\nvar queryParams = {show: \"y+e=s\", color: \"black\"};\n\nvar path = FlowRouter.path(pathDef, params, queryParams);\nconsole.log(path); // prints \"/blog/met%20eor/abc?show=y%2Be%3Ds\u0026color=black\"\n~~~\n\nIf there are no params or queryParams, this will simply return the pathDef as it is.\n\n##### Using Route name instead of the pathDef\n\nYou can also use the route's name instead of the pathDef. Then, FlowRouter will pick the pathDef from the given route. See the following example:\n\n~~~js\nFlowRouter.route(\"/blog/:cat/:id\", {\n    name: \"blogPostRoute\",\n    action: function(params) {\n        //...\n    }\n})\n\nvar params = {cat: \"meteor\", id: \"abc\"};\nvar queryParams = {show: \"yes\", color: \"black\"};\n\nvar path = FlowRouter.path(\"blogPostRoute\", params, queryParams);\nconsole.log(path); // prints \"/blog/meteor/abc?show=yes\u0026color=black\"\n~~~\n\n#### FlowRouter.go(pathDef, params, queryParams);\n\nThis will get the path via `FlowRouter.path` based on the arguments and re-route to that path.\n\nYou can call `FlowRouter.go` like this as well:\n\n~~~js\nFlowRouter.go(\"/blog\");\n~~~\n\n\n#### FlowRouter.url(pathDef, params, queryParams)\n\nJust like `FlowRouter.path`, but gives the absolute url. (Uses `Meteor.absoluteUrl` behind the scenes.)\n\n#### FlowRouter.setParams(newParams)\n\nThis will change the current params with the newParams and re-route to the new path.\n\n~~~js\n// route def: /apps/:appId\n// url: /apps/this-is-my-app?show=yes\u0026color=red\n\nFlowRouter.setParams({appId: \"new-id\"});\n// Then the user will be redirected to the following path\n//      /apps/new-id?show=yes\u0026color=red\n~~~\n\n#### FlowRouter.setQueryParams(newQueryParams)\n\nJust like `FlowRouter.setParams`, but for queryString params.\n\nTo remove a query param set it to `null` like below:\n\n~~~js\nFlowRouter.setQueryParams({paramToRemove: null});\n~~~\n\n#### FlowRouter.getRouteName()\n\nTo get the name of the route reactively.\n\n~~~js\nTracker.autorun(function() {\n  var routeName = FlowRouter.getRouteName();\n  console.log(\"Current route name is: \", routeName);\n});\n~~~\n\n#### FlowRouter.current()\n\nGet the current state of the router. **This API is not reactive**.\nIf you need to watch the changes in the path simply use `FlowRouter.watchPathChange()`.\n\nThis gives an object like this:\n\n~~~js\n// route def: /apps/:appId\n// url: /apps/this-is-my-app?show=yes\u0026color=red\n\nvar current = FlowRouter.current();\nconsole.log(current);\n\n// prints following object\n// {\n//     path: \"/apps/this-is-my-app?show=yes\u0026color=red\",\n//     params: {appId: \"this-is-my-app\"},\n//     queryParams: {show: \"yes\", color: \"red\"}\n//     route: {pathDef: \"/apps/:appId\", name: \"name-of-the-route\"}\n// }\n~~~\n\n#### FlowRouter.watchPathChange()\n\nReactively watch the changes in the path. If you need to simply get the params or queryParams use dedicated APIs like `FlowRouter.getQueryParam()`.\n\n~~~js\nTracker.autorun(function() {\n  FlowRouter.watchPathChange();\n  var currentContext = FlowRouter.current();\n  // do anything with the current context\n  // or anything you wish\n});\n~~~\n\n#### FlowRouter.withReplaceState(fn)\nNormally, all the route changes made via APIs like `FlowRouter.go` and `FlowRouter.setParams()` add a URL item to the browser history. For example, run the following code:\n\n~~~js\nFlowRouter.setParams({id: \"the-id-1\"});\nFlowRouter.setParams({id: \"the-id-2\"});\nFlowRouter.setParams({id: \"the-id-3\"});\n~~~\n\nNow you can hit the back button of your browser two times. This is normal behavior since users may click the back button and expect to see the previous state of the app.\n\nBut sometimes, this is not something you want. You don't need to pollute the browser history. Then, you can use the following syntax.\n\n~~~js\nFlowRouter.withReplaceState(function() {\n  FlowRouter.setParams({id: \"the-id-1\"});\n  FlowRouter.setParams({id: \"the-id-2\"});\n  FlowRouter.setParams({id: \"the-id-3\"});\n});\n~~~\n\nNow, there is no item in the browser history. Just like `FlowRouter.setParams`, you can use any FlowRouter API inside `FlowRouter.withReplaceState`.\n\n\u003e We named this function as `withReplaceState` because, replaceState is the underline API used for this functionality. Read more about [replace state \u0026 the history API](https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Manipulating_the_browser_history).\n\n#### FlowRouter.reload()\n\nFlowRouter routes are idempotent. That means, even if you call `FlowRouter.go()` to the same URL multiple times, it only activates in the first run. This is also true for directly clicking on paths.\n\nSo, if you really need to reload the route, this is the API you want.\n\n#### FlowRouter.wait() and FlowRouter.initialize()\n\nBy default, FlowRouter initializes the routing process in a `Meteor.startup()` callback. This works for most of the apps. But, some apps have custom initializations and FlowRouter needs to initialize after that.\n\nSo, that's where `FlowRouter.wait()` comes to save you. You need to call it directly inside your JavaScript file. After that, whenever your app is ready call `FlowRouter.initialize()`.\n\neg:-\n\n~~~js\n// file: app.js\nFlowRouter.wait();\nWhenEverYourAppIsReady(function() {\n  FlowRouter.initialize();\n});\n~~~\n\nFor more information visit [issue #180](https://github.com/meteorhacks/flow-router/issues/180).\n\n#### FlowRouter.onRouteRegister(cb)\n\nThis API is specially designed for add-on developers. They can listen for any registered route and add custom functionality to FlowRouter. This works on both server and client alike.\n\n~~~js\nFlowRouter.onRouteRegister(function(route) {\n  // do anything with the route object\n  console.log(route);\n});\n~~~\n\nLet's say a user defined a route like this:\n\n~~~js\nFlowRouter.route('/blog/:post', {\n  name: 'postList',\n  triggersEnter: [function() {}],\n  subscriptions: function() {},\n  action: function() {},\n  triggersExit: [function() {}],\n  customField: 'customName'\n});\n~~~\n\nThen the route object will be something like this:\n\n~~~js\n{\n  pathDef: '/blog/:post',\n  name: 'postList',\n  options: {customField: 'customName'}\n}\n~~~\n\nSo, it's not the internal route object we are using.\n\n## Subscription Management\n\nFor Subscription Management, we highly suggest you to follow [Template/Component level subscriptions](https://kadira.io/academy/meteor-routing-guide/content/subscriptions-and-data-management). Visit this [guide](https://kadira.io/academy/meteor-routing-guide/content/subscriptions-and-data-management) for that.\n\nFlowRouter also has it's own subscription registration mechanism. We will remove this in version 3.0. We don't remove or deprecate it in version 2.x because this is the easiest way to implement FastRender support for your app. In 3.0 we've better support for FastRender with Server Side Rendering.\n\nFlowRouter only deals with registration of subscriptions. It does not wait until subscription becomes ready. This is how to register a subscription.\n\n~~~js\nFlowRouter.route('/blog/:postId', {\n    subscriptions: function(params, queryParams) {\n        this.register('myPost', Meteor.subscribe('blogPost', params.postId));\n    }\n});\n~~~\n\nWe can also register global subscriptions like this:\n\n~~~js\nFlowRouter.subscriptions = function() {\n  this.register('myCourses', Meteor.subscribe('courses'));\n};\n~~~\n\nAll these global subscriptions run on every route. So, pay special attention to names when registering subscriptions.\n\nAfter you've registered your subscriptions, you can reactively check for the status of those subscriptions like this:\n\n~~~js\nTracker.autorun(function() {\n    console.log(\"Is myPost ready?:\", FlowRouter.subsReady(\"myPost\"));\n    console.log(\"Are all subscriptions ready?:\", FlowRouter.subsReady());\n});\n~~~\n\nSo, you can use `FlowRouter.subsReady` inside template helpers to show the loading status and act accordingly.\n\n### FlowRouter.subsReady() with a callback\n\nSometimes, we need to use `FlowRouter.subsReady()` in places where an autorun is not available. One such example is inside an event handler. For such places, we can use the callback API of `FlowRouter.subsReady()`.\n\n~~~js\nTemplate.myTemplate.events({\n   \"click #id\": function(){\n      FlowRouter.subsReady(\"myPost\", function() {\n         // do something\n      });\n  }\n});\n~~~\n\n\u003e Arunoda has discussed more about Subscription Management in FlowRouter in [this](https://meteorhacks.com/flow-router-and-subscription-management.html#subscription-management) blog post about [FlowRouter and Subscription Management](https://meteorhacks.com/flow-router-and-subscription-management.html).\n\n\u003e He's showing how to build an app like this:\n\n\u003e![FlowRouter's Subscription Management](https://cldup.com/esLzM8cjEL.gif)\n\n#### Fast Render\nFlowRouter has built in support for [Fast Render](https://github.com/meteorhacks/fast-render).\n\n- `meteor add meteorhacks:fast-render`\n- Put `router.js` in a shared location. We suggest `lib/router.js`.\n\nYou can exclude Fast Render support by wrapping the subscription registration in an `isClient` block:\n\n~~~js\nFlowRouter.route('/blog/:postId', {\n    subscriptions: function(params, queryParams) {\n        // using Fast Render\n        this.register('myPost', Meteor.subscribe('blogPost', params.postId));\n\n        // not using Fast Render\n        if(Meteor.isClient) {\n            this.register('data', Meteor.subscribe('bootstrap-data');\n        }\n    }\n});\n~~~\n\n#### Subscription Caching\n\nYou can also use [Subs Manager](https://github.com/meteorhacks/subs-manager) for caching subscriptions on the client. We haven't done anything special to make it work. It should work as it works with other routers.\n\n## IE9 Support\n\nFlowRouter has IE9 support. But it does not ship the **HTML5 history polyfill** out of the box. That's because most apps do not require it.\n\nIf you need to support IE9, add the **HTML5 history polyfill** with the following package.\n\n~~~shell\nmeteor add tomwasd:history-polyfill\n~~~\n\n## Hashbang URLs\n\nTo enable hashbang urls like `mydomain.com/#!/mypath` simple set the `hashbang` option to `true` in the initialize function:\n\n~~~js\n// file: app.js\nFlowRouter.wait();\nWhenEverYourAppIsReady(function() {\n  FlowRouter.initialize({hashbang: true});\n});\n~~~\n\n## Prefixed paths\n\nIn cases you wish to run multiple web application on the same domain name, you’ll probably want to serve your particular meteor application under a sub-path (eg `example.com/myapp`). In this case simply include the path prefix in the meteor `ROOT_URL` environment variable and FlowRouter will handle it transparently without any additional configuration.\n\n## Add-ons\n\nRouter is a base package for an app. Other projects like [useraccounts](http://useraccounts.meteor.com/)  should have support for FlowRouter. Otherwise, it's hard to use  FlowRouter in a real project. Now a lot of packages have [started to support FlowRouter](https://kadira.io/blog/meteor/addon-packages-for-flowrouter).\n\nSo, you can use your your favorite package with FlowRouter as well. If not, there is an [easy process](https://kadira.io/blog/meteor/addon-packages-for-flowrouter#what-if-project-xxx-still-doesn-t-support-flowrouter-) to convert them to FlowRouter.\n\n**Add-on API**\n\nWe have also released a [new API](https://github.com/kadirahq/flow-router#flowrouteronrouteregistercb) to support add-on developers. With that add-on packages can get a notification, when the user created a route in their app.\n\nIf you've more ideas for the add-on API, [let us know](https://github.com/kadirahq/flow-router/issues).\n\n## Difference with Iron Router\n\nFlowRouter and Iron Router are two different routers. Iron Router tries to be a full featured solution. It tries to do everything including routing, subscriptions, rendering and layout management.\n\nFlowRouter is a minimalistic solution focused on routing with UI performance in mind. It exposes APIs for related functionality.\n\nLet's learn more about the differences:\n\n### Rendering\n\nFlowRouter doesn't handle rendering. By decoupling rendering from the router it's possible to use any rendering framework, such as [Blaze Layout](https://github.com/kadirahq/blaze-layout) to render with Blaze's Dynamic Templates. Rendering calls are made in the the route's action. We have a layout manager for [React](https://github.com/kadirahq/meteor-react-layout) as well.\n\n### Subscriptions\n\nWith FlowRouter, we highly suggest using template/component layer subscriptions. But, if you need to do routing in the router layer, FlowRouter has [subscription registration](#subscription-management) mechanism. Even with that, FlowRouter never waits for the subscriptions and view layer to do it.\n\n### Reactive Content\n\nIn Iron Router you can use reactive content inside the router, but any hook or method can re-run in an unpredictable manner. FlowRouter limits reactive data sources to a single run; when it is first called.\n\nWe think that's the way to go. Router is just a user action. We can work with reactive content in the rendering layer.\n\n### router.current() is evil\n\n`Router.current()` is evil. Why? Let's look at following example. Imagine we have a route like this in our app:\n\n~~~\n/apps/:appId/:section\n~~~\n\nNow let's say, we need to get `appId` from the URL. Then we will do, something like this in Iron Router.\n\n~~~js\nTemplates['foo'].helpers({\n    \"someData\": function() {\n        var appId = Router.current().params.appId;\n        return doSomething(appId);\n    }\n});\n~~~\n\nLet's say we changed `:section` in the route. Then the above helper also gets rerun. If we add a query param to the URL, it gets rerun. That's because `Router.current()` looks for changes in the route(or URL). But in any of above cases, `appId` didn't get changed.\n\nBecause of this, a lot parts of our app get re-run and re-rendered. This creates unpredictable rendering behavior in our app.\n\nFlowRouter fixes this issue by providing the `Router.getParam()` API. See how to use it:\n\n~~~js\nTemplates['foo'].helpers({\n    \"someData\": function() {\n        var appId = FlowRouter.getParam('appId');\n        return doSomething(appId);\n    }\n});\n~~~\n\n### No data context\n\nFlowRouter does not have a data context. Data context has the same problem as reactive `.current()`. We believe, it'll possible to get data directly in the template (component) layer.\n\n### Built in Fast Render Support\n\nFlowRouter has built in [Fast Render](https://github.com/meteorhacks/fast-render) support. Just add Fast Render to your app and it'll work. Nothing to change in the router.\n\nFor more information check [docs](#fast-render).\n\n### Server Side Routing\n\nFlowRouter is a client side router and it **does not** support server side routing at all. But `subscriptions` run on the server to enable Fast Render support.\n\n#### Reason behind that\n\nMeteor is not a traditional framework where you can send HTML directly from the server. Meteor needs to send a special set of HTML to the client initially. So, you can't directly send something to the client yourself.\n\nAlso, in the server we need look for different things compared with the client. For example:\n\n* In the server we have to deal with headers.\n* In the server we have to deal with methods like `GET`, `POST`, etc.\n* In the server we have Cookies.\n\nSo, it's better to use a dedicated server-side router like [`meteorhacks:picker`](https://github.com/meteorhacks/picker). It supports connect and express middlewares and has a very easy to use route syntax.\n\n### Server Side Rendering\n\nFlowRouter 3.0 will have server side rendering support. We've already started the initial version and check our [`ssr`](https://github.com/meteorhacks/flow-router/tree/ssr) branch for that.\n\nIt's currently very usable and Kadira already using it for \u003chttps://kadira.io\u003e\n\n### Better Initial Loading Support\n\nIn Meteor, we have to wait until all the JS and other resources send before rendering anything. This is an issue. In 3.0, with the support from Server Side Rendering we are going to fix it.\n\n## Migrating into 2.0\n\nMigrating into version 2.0 is easy and you don't need to change any application code since you are already using 2.0 features and the APIs. In 2.0, we've changed names and removed some deprecated APIs.\n\nHere are the steps to migrate your app into 2.0.\n\n#### Use the New FlowRouter Package\n* Now FlowRouter comes as `kadira:flow-router`\n* So, remove `meteorhacks:flow-router` with : `meteor remove meteorhacks:flow-router`\n* Then, add `kadira:flow-router` with `meteor add kadira:flow-router`\n\n#### Change FlowLayout into BlazeLayout\n* We've also renamed FlowLayout as [BlazeLayout](https://github.com/kadirahq/blaze-layout).\n* So, remove `meteorhacks:flow-layout` and add `kadira:blaze-layout` instead.\n* You need to use `BlazeLayout.render()` instead of `FlowLayout.render()`\n\n#### Stop using deprecated Apis\n* There is no middleware support. Use triggers instead.\n* There is no API called `.reactiveCurrent()`, use `.watchPathChange()` instead.\n* Earlier, you can access query params with `FlowRouter.current().params.query`. But, now you can't do that. Use `FlowRouter.current().queryParams` instead.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkadirahq%2Fflow-router","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkadirahq%2Fflow-router","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkadirahq%2Fflow-router/lists"}