Search code examples
meteoriron-router

Update Query Param with Iron Router


I'm trying to figure out the least brittle way to update a query param in Iron Router.
Flow-Router has FlowRouter.setParams({step: 2}) which is ideal.

Currently i'm using this but I wanted to check if there's a better way (especially since the IR API changes so frequently)

var currentId = Router.current().params.id;
var newStep = '2';
Router.go('checkout', {id: currentId}, {query: 'step=' + newStep});

Solution

  • This is the correct way, but you can use the object syntax for the query just like in FlowRouter.

    Router.go('checkout', {
      id: currentId
    }, {
      query: {
        step: 2
      }
    });