useSearchParams in React
Streaming AI responses is one of the easiest ways to improve UX. Here’s how to implement it in a Next.js app using the Vercel AI SDK—typing effect, reasoning, and all.

Learn how React Router’s Middleware API fixes leaky redirects and redundant data fetching in protected routes.

A developer’s retrospective on creating an AI video transcription agent with Mastra, an open-source TypeScript framework for building AI agents.

Learn how TanStack DB transactions ensure data consistency on the frontend with atomic updates, rollbacks, and optimistic UI in a simple order manager app.
Hey there, want to help make our blog better?
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/