# Migrating from router(-direct) to router(-lite): params / queryParams

**URL:** <https://discourse.aurelia.io/t/migrating-from-router-direct-to-router-lite-params-queryparams/6484>\
**Category:** vNext\
**Created:** [July 18, 2025, 9:01am UTC](https://discourse.aurelia.io/t/migrating-from-router-direct-to-router-lite-params-queryparams/6484 "2025-07-18T09:01:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![migajek](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/migajek/32/379_2.png) [@migajek](https://discourse.aurelia.io/u/migajek)\
**Post date:** [July 18, 2025, 9:01am UTC](https://discourse.aurelia.io/t/migrating-from-router-direct-to-router-lite-params-queryparams/6484/1 "2025-07-18T09:01:23Z")

</div>

Hi, preparing a migration plan, I found out there seem to be a significant difference in how _extra params_ (queryParams) are handled. By _extra params_ I mean the parameters that are **not** explicitly specified in the route definition.

- In router-direct, all the params passed to the route, would end up in the “params” argument of canLoad: `/list/:category + /list/root?sort=name -> params: {category: root, sort: name}`
- In router-lite, only the parameters that are explicitly defined in the route are passed: `/list/:category + /list/root?sort=name -> params: {category: root}`. The remaining are available via `next.queryParams: {sort: name}`

I understand this is by design [as stated here](https://discourse.aurelia.io/t/optional-params-in-router-lite-by-params-object/5142/2) by @Sayan751 and frankly it does make sense to me.

However, since this is a migration scenario (and now that router-lite became the default router it might be quite common soon) I am wondering whether it might be possible to override the behavior and pass the combined params + queryParams for the sake of compatibility with router(-direct)?  
I tried the lifecycleHooks but it seems `params` is read-only there.

---

<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:** [July 19, 2025, 6:46pm UTC](https://discourse.aurelia.io/t/migrating-from-router-direct-to-router-lite-params-queryparams/6484/2 "2025-07-19T18:46:24Z")

</div>

Hi @migajek, is it enough if the combined parameters are provided to the hook methods, such as `canLoad` or `loading`?

---

<div class="post-metadata">

**Author:** ![migajek](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/migajek/32/379_2.png) [@migajek](https://discourse.aurelia.io/u/migajek)\
**Post date:** [July 21, 2025, 9:30am UTC](https://discourse.aurelia.io/t/migrating-from-router-direct-to-router-lite-params-queryparams/6484/3 "2025-07-21T09:30:22Z")

</div>

Hi @Sayan751, I believe it would be enough. Obtaining the current route need code changes anyway 🙂

I just wonder whether that would be feasible to allow mutating in the hooks, that’d make it quite flexible 🙂

---

<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:** [July 21, 2025, 6:35pm UTC](https://discourse.aurelia.io/t/migrating-from-router-direct-to-router-lite-params-queryparams/6484/4 "2025-07-21T18:35:14Z")

</div>

I have opened the PR here: [chore(router): added an option to treat query parameters as path parameters by Sayan751 · Pull Request #2209 · aurelia/aurelia · GitHub](https://github.com/aurelia/aurelia/pull/2209). Feel free to have a look.

> I just wonder whether that would be feasible to allow mutating in the hooks, that’d make it quite flexible 🙂

It is not. Both the configured parameters and the unconfigued query parameters come from either the browser URL or the routing instruction (whatever you are passing to the `Router#load`) and those are assumed readonly for obvious reason.

May I ask what use-case you want to address by changing the parameters from the hook?

---

<div class="post-metadata">

**Author:** ![migajek](https://yyz1.discourse-cdn.com/flex027/user_avatar/discourse.aurelia.io/migajek/32/379_2.png) [@migajek](https://discourse.aurelia.io/u/migajek)\
**Post date:** [August 4, 2025, 11:42am UTC](https://discourse.aurelia.io/t/migrating-from-router-direct-to-router-lite-params-queryparams/6484/5 "2025-08-04T11:42:43Z")

</div>

Sorry for the late reply, been on vacation 🙂

The only reason I wanted to alter the parameters in the hook, was to pass the query params as params without the changes to aurelia router itself 🙂

---

<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:** [August 4, 2025, 5:43pm UTC](https://discourse.aurelia.io/t/migrating-from-router-direct-to-router-lite-params-queryparams/6484/6 "2025-08-04T17:43:15Z")

</div>

@migajek The said PR is merged. So feel free to try it out. The docs are her: [Router configuration | The Aurelia 2 Docs](https://docs.aurelia.io/getting-to-know-aurelia/routing/aurelia-router/router-configuration#treat-query-parameters-as-path-parameters).

In case there is any residual issues, please share a minimal reproduction, so that it is easier to understand the problem.
