ROUTING strategy

Hi everyone,

I can’t find a tutorial using meteor 1.3+ with “imports” structure recommendation and routing (flow-router-extra).

Can someone point me to that ?

More precisely, I would like to know what is “the easiest” (and “best”/“maintainable” :grin: )
way to structure files when using layouts and routes.

I find something like that :

imports/
  startup/
    client/              
      routes.js                      
  ui/
    components/               
    layouts/                                      
client/
  main.html 
  main.js                   

with main.js importig routes.js
and routes.js importing all files in layouts and components

But routes.js file include all routes declarations and all layouts/components imports. (Big file !)

Is it possible to split the route.js in a route directory with
route1.js
route2.js

routeN.js

And importing only the route directory in main.js (import ./route, meaning importing all files of route directory)

same question for layouts and components, without repeating in each routeN.js file.

It seems too complicated, maybe I am doing it bad ?

Thx for your help.

You can load routes asynchronously, just look at the flow-router-extra docs

Or you can make the action async like

FlowRouter.route("/theRouteURL", {
  name: "theNameOfTheRoute",
  template:'nameOfTheTemplate',
  // waitOn(){
  //   import "/imports/pages/theFileWithTheTemplate";
  // }
  async action(params) {
    import "/imports/pages/theFileWithTheTemplate";
    this.render("layout", "nameOfTheTemplate");
  },
});