Flow Router and /#!/


#1

I just upgraded from IR to Flow Router. One thing I’d like to understand is, with Flow Router, why do I get this extra /#!/ before all my routes?

For example in IR I would have a route name /come-here. I the url bar it would look like this ‘mywebsite.com/come-here’. But in Flow Router its like this 'mywebsite.com/#!/come-here instead.

I can’t find reference to this in the docs.


#2

That’s not needed, can you show how you implemented? And do you use the latest versions?


#3

I’m using:

kadira:flow-router 2.12.1
kadira:blaze-layout 2.3.0
arillo:flow-router-helpers 0.5.2

I have a layout template like so:

<template name="mainLayout">
    {{#if isAdmin}}
    	{{> dashboardSidebar}}
    {{/if}}

    {{#if isUser}}
        {{> leftSideSidebar "aside"}}
    {{/if}}

    {{> Template.dynamic template=main}}

    {{> Template.dynamic template=rightSide}} 
</template>

<template name="secondaryLayout">
  {{> Template.dynamic template=header}}

  {{> Template.dynamic template=leftSide}}

  <div class="row"
      {{> Template.dynamic template=rightSide}}
  </div>
  <div class="row"
      {{> Template.dynamic template=main}}
  </div>

</template>

Here are a few regular routes:

FlowRouter.route( '/alerts', {
  action: function() {
    BlazeLayout.render( 'mainLayout', { main: 'alerts' } ); 
  },
  name: 'alerts.view'
});
FlowRouter.route( '/messages', {
  action: function() {
    BlazeLayout.render( 'mainLayout', { main: 'user' } ); 
  },
  name: 'user.view'
});

FlowRouter.route( '/another-route', {
  action: function() {
      BlazeLayout.render( 'secondaryLayout', { header: 'userDashboardHeader', leftSide: 'sideBar1', main: 'mainBlazeArea', rightSide: 'anotherBlazeNav' } ); 
  },
  name: 'goodRoute.view'
});

#4

No obvious mistake. Are you doing below on your code:

FlowRouter.wait();
WhenEverYourAppIsReady(function() {
  FlowRouter.initialize({hashbang: true});
});

#5

Yes, I have this in a shared dir:


FlowRouter.wait();
Meteor.startup(function() {
    FlowRouter.initialize({ hashbang: true });
});

#6

Ha, removing that line did the trick! Thank you @vyky!


#7

Glad it helped. Flow router look like won’t be maintained anyway.


#8

The only other router I hear people use around here is React Router – and AFAIK that doesn’t have the hooks for Blaze templating.