title: How to load routes from DB in Meteor before everything?
body: <p>I have this code to create routes from database in Meteor:</p>
  
  <pre><code>if (Meteor.isClient) {
    Meteor.subscribe("routes", function() {
      Routes.find({}).map(function(route) {
        try {
          Router.route(route.path, {
            name: route.name,
            waitOn: function() {
              var subscribes = [];
              if (typeof route.subscriptions== 'object' &amp;&amp;
                route.subscriptions
                .length &gt; 0) {
                route.subscriptions.forEach(function(subscription) {
                  subscribes.push(Meteor.subscribe(
                    subscription));
                });
              }
              return subscribes;
            },
            action: function() {
              this.render(route.template);
            }
          });
        } catch (e) {
          console.log("Error: " + e);
        }
      });
    });
  }
  </code></pre>
  
  <p>So when I type in browser a path to a route from db gives this error:</p>
  
  <p>Oops, looks like there's no route on the client or the server for url: "<a href="https://localhost:3000/menus" rel="nofollow">https://localhost:3000/menus</a>."</p>
  
  <p>I think its because this code runs after pageloads. How can I work around it?</p>