Sets new search params and causes a navigation when called.
<button onClick={() => { const params = new URLSearchParams(); params.set("someKey", "someValue"); setSearchParams(params, { preventScrollReset: true, }); }}/> Copy
<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; }); }}/> Copy
<button onClick={() => { setSearchParams((prev) => { prev.set("someKey", "someValue"); return prev; }); }}/>
Sets new search params and causes a navigation when called.
It also supports a function for setting new search params.