Search code examples
meteorflow-router

How to pass variables to FlowRouter 'named routes'?


I have the following route:

FlowRouter.route('/users/:_id/edit', {
    name: 'Users.edit',
    action() {
        BlazeLayout.render('App_body', { main: 'Users_edit_page' });
    },
});

And I can access the appropriate page with the following code:

var userId = Meteor.userId();
FlowRouter.go('/users/' + userId + '/edit');

How do you pass the userId through to Users.edit name, instead of using the URI path.

Incidentally, I read somewhere that FlowRouter doesn't have named routes - is this not a named route?


Solution

  • FlowRouter.go('Users.edit', {id: 1});

    See here: https://github.com/kadirahq/flow-router#api