explaingit

47ng/nuqs

10,430TypeScriptAudience · developerComplexity · 2/5Setup · easy

TLDR

A TypeScript library for React that stores UI state in the URL instead of memory, making filter values, search terms, and settings shareable and preserved across page refreshes.

Mindmap

mindmap
  root((repo))
    What it does
      URL query state
      Replaces useState
      Shareable app state
    Supported Frameworks
      Next.js
      Remix
      TanStack Router
      Plain React
    Features
      Type-safe parsing
      Back button support
      Server rendering
      Built-in converters
    Audience
      React developers
      Frontend engineers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Store search filters and sort settings in the URL so users can share or bookmark the exact page state.

USE CASE 2

Replace useState with a URL-backed hook so filter selections survive page refreshes in a React or Next.js app.

USE CASE 3

Add back-button support to filter changes in a Next.js app by treating URL state updates as browser history entries.

USE CASE 4

Read URL query parameters in server-rendered Next.js App Router components with full TypeScript type safety.

Tech stack

TypeScriptReactNext.js

Getting it running

Difficulty · easy Time to first run · 5min

Requires adding a small framework adapter at the top of the component tree, the exact wrapper differs per router.

In plain English

nuqs is a TypeScript library for React that stores UI state directly in the URL's query string rather than in memory. A URL query string is the part after the question mark in a web address, like the word "search" in something like "example.com/results?search=hello". Normally, React developers use a built-in tool called useState to hold values like form fields or filter selections in memory, but those values disappear if you refresh the page or share the link. nuqs keeps those values in the URL instead, making them shareable and persistent across page loads. The library works similarly to React's useState in terms of how you write code: you call a hook, get back a current value and a function to update it, and the URL reflects the change automatically. It includes built-in converters for common types like integers, floating point numbers, booleans, dates, arrays, and JSON objects, so you do not have to manually convert URL strings into the types your code actually needs. The library supports several popular React frameworks including Next.js (both its older pages-based router and the newer app router), plain single-page React apps, Remix, React Router, and TanStack Router. Each framework needs a small wrapper added at the top of the component tree to handle the differences in how each one reads and writes URLs. Other features include the ability to treat URL updates like browser history entries, so users can press the back button to undo a state change, and a way for server-rendered components to read the same query parameters in a type-safe way. Full documentation lives at nuqs.dev.

Copy-paste prompts

Prompt 1
Help me replace a React useState hook in my product filter component with nuqs so the selected filters appear in the URL and persist on page refresh.
Prompt 2
I'm building a Next.js search page. Show me how to use nuqs to store the search term, page number, and sort order as typed URL query parameters.
Prompt 3
How do I set up nuqs in a React app that uses TanStack Router so that query params are synced to the URL automatically on every filter change?
Prompt 4
Help me use nuqs on the server side in a Next.js App Router page to read typed query parameters without any client-side JavaScript.
Open on GitHub → Explain another repo

← 47ng on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.