SetURLSearchParams: ((nextInit?: URLSearchParamsInit | ((prev: URLSearchParams) => URLSearchParamsInit), navigateOpts?: NavigateOptions) => void)

Sets new search params and causes a navigation when called.

<button
onClick={() => {
const params = new URLSearchParams();
params.set("someKey", "someValue");
setSearchParams(params, {
preventScrollReset: true,
});
}}
/>

It also supports a function for setting new search params.

<button
onClick={() => {
setSearchParams((prev) => {
prev.set("someKey", "someValue");
return prev;
});
}}
/>