[Solved] FlowRouter set default url parameters


Hey guys
Is there way to set default parameters to route? I need some approach to change query parameters to defaults when route is entered
I tried to call setQueryParams in route root onCreated template callback and in route triggers. Also tried to change queryParams in route triggers. All this leads to the same result:

  1. go to route (https://some-url/)
  2. set queryParams (https://some-url?param=value)
  3. push url with params to history (https://some-url?param=value)
  4. push initial url to history (https://some-url)

it happens only in case when user goes to route by clicking a link
Also route state is correct: query params are already set. I think problem is in pushing state to history.
Will appreciate any idea


Hello @bogdans,

Only .go() method will add new entries into browser history.


Actually Router.prototype.setQueryParams uses this method
Any idea how to predefine parameters correctly? Maybe I do smth wrong


You’re right, my bad.

You can use triggersEnter API to check if param exists and not empty, if it is, then redirect using redirect function, which passed as second argument into triggersEnter hook.


Worked perfectly for me, thanks