http://localhost:3000/?search=test&type=abc&category=xyz
After I search for test (among with type and category), the URL changes to the URL above.
return router.push(
{
pathname: `/`,
query: {
// something to do here...
},
},
"",
{ scroll: false }
);
Next, I have an onClick with this router.push.
I would like to remove ONLY the search query and keep the type and category queries. How is it possible? The documentation doesn't mention anything about this.
To remove the query param completely from the url:
const { paramToRemove, ...routerQuery } = router.query;
router.replace({
query: { ...routerQuery },
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With