# Modify routing parameters

**URL:** <https://discourse.aurelia.io/t/modify-routing-parameters/4018>\
**Category:** Help Requests\
**Created:** [February 5, 2021, 10:20am UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018 "2021-02-05T10:20:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gama410](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/gama410/32/1153_2.png) [@gama410](https://discourse.aurelia.io/u/gama410)\
**Post date:** [February 5, 2021, 10:20am UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018/1 "2021-02-05T10:20:24Z")

</div>

I’m trying to find a way to safely modify the routing parameters in an routing pipeline step.

My problem is that I have a page that might require rather complicated activation parameters and those must be configurable and stored in database along with the navigation menu structure.  
What I was thinking was to just add a query string parameter to the link (like ?get\_config=1) and, in a preActivate step, if I have the parameter, fetch the configuration from the server before forwarding the request with this config added to the parameters that will be passed to the activate method of the viewmodel.

I tried modifying the routingContext in my pipeline step but with no effect on the activation parameters. Aurelia seem to be getting those from another object and I’m not sure if I can safely modify anything in there…

Any idea?

---

<div class="post-metadata">

**Author:** ![gama410](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/gama410/32/1153_2.png) [@gama410](https://discourse.aurelia.io/u/gama410)\
**Post date:** [February 10, 2021, 8:52am UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018/2 "2021-02-10T08:52:55Z")

</div>

No idea anyone? I’m a bit stumped here, anything would be really helphful! 🥺

---

<div class="post-metadata">

**Author:** ![Sayan751](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sayan751/32/1861_2.png) [@Sayan751](https://discourse.aurelia.io/u/Sayan751)\
**Post date:** [February 10, 2021, 10:44am UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018/3 "2021-02-10T10:44:59Z")

</div>

Doesn’t it make more sense to fetch those config in the `canActivate`/`activate` hook of the individual routed view-models?

---

<div class="post-metadata">

**Author:** ![gama410](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/gama410/32/1153_2.png) [@gama410](https://discourse.aurelia.io/u/gama410)\
**Post date:** [February 10, 2021, 11:37am UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018/4 "2021-02-10T11:37:11Z")

</div>

Thanks for your answer.  
Actually, it would be easier but I would like this mechanism to fit inside the architecture instead of being a responsibility of the individual modules’ developers.  
In that optic, it would be nice if the dev just received the configuration in the activation parameters as any routing param instead of having to fetch it himself and having to know the underlying structure…

---

<div class="post-metadata">

**Author:** ![Sayan751](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/sayan751/32/1861_2.png) [@Sayan751](https://discourse.aurelia.io/u/Sayan751)\
**Post date:** [February 10, 2021, 12:46pm UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018/5 "2021-02-10T12:46:06Z")

</div>

In that case, you might want to consider aurelia-store. An approach can be that you read the parameters from the route, populate the store, and the individual routed view-models subscribe to store; thereby when the property is changed from pipeline step, the view models are notified of the change.

As far as I can remember, the router parameters are frozen.

---

<div class="post-metadata">

**Author:** ![gama410](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/gama410/32/1153_2.png) [@gama410](https://discourse.aurelia.io/u/gama410)\
**Post date:** [February 10, 2021, 12:54pm UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018/6 "2021-02-10T12:54:31Z")

</div>

Ok thank you @Sayan751 . I’ll try to work in another direction (maybe not the store because I don’t want to add this plugin just for that case). Thank you!

If anyone else has additional insight, I’m still interested, though!

---

<div class="post-metadata">

**Author:** ![gama410](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/gama410/32/1153_2.png) [@gama410](https://discourse.aurelia.io/u/gama410)\
**Post date:** [February 10, 2021, 1:13pm UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018/7 "2021-02-10T13:13:36Z")

</div>

I just tried to modify the lifecycleArgs of the instruction in a pipeline step and I seem to get my information in the activate method so apparently it is possible to modify them.

> ```
> routingContext.lifecycleArgs[0]['custom'] = {param1: 'param1', param2: 123, param3: [1,2,3]};
> 
> ```

and I received the info correctly.  
 ![image](https://canada1.discourse-cdn.com/flex027/uploads/aurelia/original/2X/f/fb15d9550698fc69a40998fb3556bac62e3fe855.png)

I’m not really sure this is safe and won’t break routing with a child view or something, though…

---

<div class="post-metadata">

**Author:** ![avrahamcool](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/avrahamcool/32/368_2.png) [@avrahamcool](https://discourse.aurelia.io/u/avrahamcool)\
**Post date:** [February 10, 2021, 8:36pm UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018/8 "2021-02-10T20:36:59Z")

</div>

maybe instead of trying to modify the url parameters you can use a redirect.  
create a route that doe’s nothing except redirecting to other routes.  
so you might have a url like “/redirect?config=1” pointing to a “redirect component”.  
in the “activate” lifecycle of that component - you fetch the data based on the configId you got in the url, and then perform a redirect to a new route with real parameters.  
that way - you can navigate to those routes using the real url, or by using the “redirect” url.

---

<div class="post-metadata">

**Author:** ![gama410](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/gama410/32/1153_2.png) [@gama410](https://discourse.aurelia.io/u/gama410)\
**Post date:** [February 11, 2021, 9:33am UTC](https://discourse.aurelia.io/t/modify-routing-parameters/4018/9 "2021-02-11T09:33:52Z")

</div>

That’s a good idea! It’s pretty simple and it will clean the URL at the same time!  
Thank you, I’ll try that!
