Type-Safe URL State Management in React With nuqs

This ad is not shown to multipass and full ticket holders
React Summit
React Summit 2026
June 11 - 15, 2026
Amsterdam & Online
The biggest React conference worldwide
Learn More
In partnership with Focus Reactive
Upcoming event
React Summit 2026
React Summit 2026
June 11 - 15, 2026. Amsterdam & Online
Learn more
Bookmark
SlidesGithubProject website
Rate this content

There are many ways to manage state in modern React applications, but the URL itself is a powerful hidden state manager that’s often overlooked.

This talk introduces `nuqs`, a library that simplifies URL state management in React. We’ll explore the benefits this approach: shareability, history navigation, and declarative client-server interaction.

Through a live demo, you’ll learn how to migrate from React.useState to nuqs’ useQueryState while we navigate concepts like client-only vs server-aware search parameters. We’ll also cover good practices for type-safe, pretty URLs, and how to avoid common pitfalls such as browser rate limits and URL size constraints.

If you’ve ever wondered what state belongs in the URL, and how to scale it, this talk will give you the answers.

This talk has been presented at React Advanced 2025, check out the latest edition of this React Conference.

FAQ

Using URL state allows for teleportation, where you share a link to share the application's state with others, and time travel, enabling users to bookmark or navigate browser history to recall past states.

Some limitations include URL size limits, the potential for shared links to become outdated, browser rate limits on URL updates, entry points affecting the state machine, and SEO considerations.

François Best is a freelance software engineer from Grenoble in the French Alps, known for creating the nuqs library.

Nuqs is a type-safe search params state manager for React, designed to make URL states enjoyable and functional in React applications.

Yes, nuqs is an open-source library with almost 10,000 stars on GitHub and over a million weekly downloads.

Yes, nuqs can integrate with validation schemas like Zod, especially with Zod 4.1 which allows bidirectional transforms for serialization and deserialization.

Nuqs does not handle compression by default, but custom parsers can be created to compress and decompress query parameters.

Nuqs itself does not prevent script injection attacks, but developers can create parsers that validate and sanitize URL inputs to prevent such vulnerabilities.

Yes, nuqs can be integrated with libraries like Zustand and Redux to synchronize state management with URL parameters.

Yes, nuqs supports arrays in query parameters both by using a compact form with a separator and by repeating keys for multiple values.

François Best
François Best
30 min
28 Nov, 2025

Comments

Sign in or register to post your comment.
Video Summary and Transcription
François Best introduces nuqs, a URL state manager for React, offering teleportation and time travel abilities. Nuqs addresses browser rate limits on URL updates and creates entry points into the app by putting state in the URL. Nuqs allows for server-side rendering and shareable UI creation with a declarative approach. URL source is used as a truth for state handling and debouncing URL updates is finalized in nuqs. Type-safe URL parameter handling and compression parsing are supported, ensuring security and routing safety with TanStack integration.

1. Understanding URL State in React

Short description:

François Best, a software engineer, introduces nuqs, a type-safe search params state manager for React. Storing state in the URL offers teleportation and time travel abilities. The URL serves as a bi-directional communication link between client and server, allowing data exchange. Understanding limitations of URL state is crucial for engineers.

Hello, everyone. My name is François Best. I'm a freelance software engineer from Grenoble in the French Alps. And so today I want to talk to you about this library that I made called nuqs. It is used by companies around the world like Sentry, Supabase, Vercel, Clerk, and many more. And it is a type-safe search params state manager for React. Its goal is to make URL states enjoyable in React, in all of React, all of those supported types.

What is URL state exactly? It's the idea of storing some of the state of our application into the search params or query string that key value store after the question mark part of the URL. Why would you want to do this? There is a wrong reason. If what you want to achieve is not losing the state updates that you did when you reload the page, that's not a good reason enough on its own to put it in the URL. Because reload resilience is more of a side effect, and you can achieve it with other means like local storage, for example.

The real reason you want to put states in the URL is that it gives your applications two superpowers. The first one is teleportation. By sharing a link with someone else, you teleport the memory representation of that state from your browser into theirs, so they can see the same thing as you do, pick up where you left off. This is also something we call deep linking. The second superpower is time travel. A bookmark is a way to send a link forward in time to your future self. Your browser history is a way to travel back in time, to recall states from the past. If you use the browser's back forward button to time travel debug your state like an undo-redo, just be aware that you may break the back button. Be aware of that.

So how does it work in practice? If we see the URL as the boundary between the client and the server, it becomes this natural place for them to exchange data between each other. The client can attach some states on the request for the document that it's on, the server picks that up, uses it for data fetching, filtering, rendering custom content. Nothing new about this part. This is how the web has been working forever. The main difference is that now we have a client that can react to changes in the URL, and so the server can also reply using the same system. With a redirect, it can pass some state back to the client for it to handle client side. So we have this bi-directional communication link between the client and the server using only the URL text, which is pretty powerful. Now, there are some caveats to this approach, and I think as good engineers it's important that we know the limitations of the systems that we're working with. So I will go through five different problems that you can encounter with URL state. The first one is that the URL has a size limit.

2. Challenges of URL State Management

Short description:

Long links pose a social limitation. Control over shared links is essential. Nuqs addresses browser rate limits on URL updates for security. Entry points into the app are created by putting state in the URL.

The practical limitation is not going to be a technical one, it is a social one. It is that of us humans, because we don't like long links. For example, between these two links, which are semantically equivalent, they both represent a 10-stack table state, which one would you rather click on? The second one, exactly. Because first, it looks less scary, it is smaller, so it fits our criteria. But you can also understand what it's going to do just by reading it. It is a user interface. It is the first user interface that your users will see before they land on your application. So you want to design your links at least as well as your open graph images.

The second problem that we might have with this is that once users have shared links across the internet, they're out of your control. And if you want to introduce breaking changes in the search programs that you accept in your page, you will have to now run migrations against those URLs that come in. Because you don't want to break existing links. Cool URLs don't change, you want to honor the semantics of the links that have been shared in the past for as long as you can. And so, this can be done with migrations middleware and redirects to pass back to your application the result of the migrated URL.

Another problem that's not super well known is that browsers rate limit URL updates when you update them client-side, for security reasons. And nuqs solves this with a feature that I like to call time safety, which is decoupling of the UI. So you have instant optimistic local state updates for metrics like AMP and keeping your application responsive. And on the other side, throttling the URL updates at a rate that the browser can handle. You notice that they actually don't have the same rate. So it needs to adapt for this. And on top of this, you can add some debounce semantics in case you're only interested in the final state for high-frequency updates like text inputs or a slider, for example. Another problem that you can encounter is that by putting state in the URL, you create entry points into your application.

QnA

Check out more articles and videos

We constantly think of articles and videos that might spark Git people interest / skill us up or help building a stellar career

Everything Beyond State Management in Stores with Pinia
Vue.js London Live 2021Vue.js London Live 2021
34 min
Everything Beyond State Management in Stores with Pinia
Top Content
State management is not limited to complex applications and transitioning to a store offers significant benefits. Pinia is a centralized state management solution compatible with Vue 2 and Vue 3, providing advanced devtools support and extensibility with plugins. The core API of Pinia is similar to Vuex, but with a less verbose version of stores and powerful plugins. Pinia allows for easy state inspection, error handling, and testing. It is recommended to create one file per store for better organization and Pinia offers a more efficient performance compared to V-rex.
Using useEffect Effectively
React Advanced 2022React Advanced 2022
30 min
Using useEffect Effectively
Top Content
Today's Talk explores the use of the useEffect hook in React development, covering topics such as fetching data, handling race conditions and cleanup, and optimizing performance. It also discusses the correct use of useEffect in React 18, the distinction between Activity Effects and Action Effects, and the potential misuse of useEffect. The Talk highlights the benefits of using useQuery or SWR for data fetching, the problems with using useEffect for initializing global singletons, and the use of state machines for handling effects. The speaker also recommends exploring the beta React docs and using tools like the stately.ai editor for visualizing state machines.
React Query: It’s Time to Break up with your "Global State”!
React Summit Remote Edition 2020React Summit Remote Edition 2020
30 min
React Query: It’s Time to Break up with your "Global State”!
Top Content
Global state management and the challenges of placing server state in global state are discussed. React Query is introduced as a solution for handling asynchronous server state. The Talk demonstrates the process of extracting logic into custom hooks and fixing issues with state and fetching logic. Optimistic updates with mutation are showcased, along with the benefits of using React Query for data fetching and mutations. The future of global state management is discussed, along with user feedback on React Query. The Talk concludes with an invitation to explore React Query for server state management.
Jotai Atoms Are Just Functions
React Day Berlin 2022React Day Berlin 2022
22 min
Jotai Atoms Are Just Functions
Top Content
State management in React is a highly discussed topic with many libraries and solutions. Jotai is a new library based on atoms, which represent pieces of state. Atoms in Jotai are used to define state without holding values and can be used for global, semi-global, or local states. Jotai atoms are reusable definitions that are independent from React and can be used without React in an experimental library called Jotajsx.
Announcing Starbeam: Universal Reactivity
JSNation 2022JSNation 2022
27 min
Announcing Starbeam: Universal Reactivity
Starbeam is a library for building reactive user interfaces with JavaScript, similar to Svelte, Vue, and Ember. It provides a data structure and query feature for filtering and sorting. The useStarBeam function ensures JSX reconciliation only occurs when reactive dependencies change. Starbeam tracks every read and write operation to update the component accordingly. It can be used with React and other frameworks, and offers debugging tools and locale integration.
Thinking in React Query
React Summit 2023React Summit 2023
22 min
Thinking in React Query
Top Content
Watch video: Thinking in React Query
React Query is not a data fetching library, but an Asian state manager. It helps keep data up to date and manage agent life cycles efficiently. React Query provides fine-grained subscriptions and allows for adjusting stale time to control data fetching behavior. Defining stale time and managing dependencies are important aspects of working with React Query. Using the URL as a state manager and Zustand for managing filters in React Query can be powerful.

Workshops on related topic

Rethinking Server State with React Query
React Summit 2020React Summit 2020
96 min
Rethinking Server State with React Query
Top Content
Featured Workshop
Tanner Linsley
Tanner Linsley
The distinction between server state and client state in our applications might be a new concept for some, but it is very important to understand when delivering a top-notch user experience. Server state comes with unique problems that often sneak into our applications surprise like:
- Sharing Data across apps- Caching & Persistence- Deduping Requests- Background Updates- Managing “Stale” Data- Pagination & Incremental fetching- Memory & Garbage Collection- Optimistic Updates
Traditional “Global State” managers pretend these challenges don’t exist and this ultimately results in developers building their own on-the-fly attempts to mitigate them.
In this workshop, we will build an application that exposes these issues, allows us to understand them better, and finally turn them from challenges into features using a library designed for managing server-state called React Query.
By the end of the workshop, you will have a better understanding of server state, client state, syncing asynchronous data (mouthful, I know), and React Query.
State Management in React with Context and Hooks
React Summit Remote Edition 2021React Summit Remote Edition 2021
71 min
State Management in React with Context and Hooks
Workshop
Roy Derks
Roy Derks
A lot has changed in the world of state management in React the last few years. Where Redux used to be the main library for this, the introduction of the React Context and Hook APIs has shaken things up. No longer do you need external libraries to handle both component and global state in your applications. In this workshop you'll learn the different approaches to state management in the post-Redux era of React, all based on Hooks! And as a bonus, we'll explore two upcoming state management libraries in the React ecosystem.