useSearchParams in React
Learn how to build a Next.js 16 Progressive Web App with true offline support, using IndexedDB, service workers, and sync logic to keep your app usable without a network.

Discover what’s new in The Replay, LogRocket’s newsletter for dev and engineering leaders, in the January 14th issue.

This tutorial explores how to build a robust, state-machine-driven lead qualification system using n8n, a persistent data layer (n8n data tables), and an external CRM (GoHighLevel).

VSCode has architectural performance limits. Compare six fast, native code editors built for lower resource usage.
Would you be interested in joining LogRocket's developer community?
Join LogRocket’s Content Advisory Board. You’ll help inform the type of content we create and get access to exclusive meetups, social accreditation, and swag.
Sign up now
5 Replies to "Why URL state matters: A guide to <code>useSearchParams</code> in React"
You can update search params easily with this approach, using native useSearchParams functional update.
setSearchParams((searchParams) => {
searchParams.set(“greeting”, “hi”);
return searchParams;
});
Hi,
Great post!
It would be nice to see a section on how to manage updating multiple keys at the same time.
For example if you set State A then State B you will end up with only State B’s changes.
In my case I am trying to update a start and end date that are updated by the same callback function.
Cheers,
Casey
The first example of useState calls setTotal instead of setGreeting
Thanks for the heads-up, this has been fixed
Created a library to simplify storing state in URL https://www.reddit.com/r/nextjs/comments/17d4x2k/about_using_url_for_managing_state_in_nextjs_13/