Search code examples
vuejs3nuxt.jsvitenuxt3.js

Issue with Query params(automatic reset of query params on any page file save)


In my Nuxt 3 application, I'm experiencing an issue with query parameters being lost during Hot Module Replacement (HMR).

When I modify any file in the pages directory, on updating any of the page I notice:

  • Query parameters are lost after the HMR update
  • Terminal shows routes.mjs being updated:

hmr update /pages/upload/index.vue, /pages/upload/index.vue?macro=true, /@id/virtual:nuxt:C:/Projects/nexus_sync/nexus-sync-v2/nexus-sync-ui/.nuxt/routes.mjs

However, when I modify a component file:

  • Query parameters persist correctly
  • Terminal only shows component update:

hmr update /components/Text.vue

What's the recommended way to preserve query parameters during HMR when modifying page files in Nuxt 3?

Why the params being lost on any update in any of the pages files.

Is this because of vite or something else. I have firstly the url is something like this http://localhost:3002/test?a=1

And when something is changed in page files, Url becomes http://localhost:3002/test

query params are lost


Solution

  • Got Fixed, As there were some external dependencies in my project which were of no use. I removed them and updated the existing ones to latest version. Now query params are working as expected