nuqs

Applies best practices for type-safe URL query state management with nuqs in Next.js and React.

Updated Aug 15, 2025
One-click install
npx skills add https://github.com/yehezkieldio/topaz --skill nuqs-yehezkieldio
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: nuqs
Source: https://github.com/yehezkieldio/topaz/tree/main/.agents/skills/nuqs
Command: npx skills add https://github.com/yehezkieldio/topaz --skill nuqs-yehezkieldio

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) and assets (resource) components.

What problem does it solve? URL query state in React apps is error-prone: untyped string parameters cause runtime type errors, missing adapter setup breaks hooks silently, and unthrottled URL writes trigger browser rate limits and excessive server re-renders. This Skill provides 39 prioritized rules so AI agents generate correct nuqs code the first time. ## Core Features & Use Cases - Parser Configuration Rules: Covers typed parsers, enum validation, JSON validation with Standard Schema, array formats, date parsers, and withDefault for non-nullable state. - Setup & Server Integration: Enforces NuqsAdapter wrapping, 'use client' directives, nuqs/server imports, createSearchParamsCache/createLoader usage, and Next.js 15 async searchParams handling. - Performance & History Guidance: Covers limitUrlUpdates debounce/throttle, key isolation, shallow:false server refetching, useTransition loading states, and push vs replace history modes. - Use Case: When adding a paginated, filterable search page to a Next.js app, the agent applies these rules to configure parsers, debounce the search input, and wire server-side refetching correctly. ## Quick Start Ask the agent to review or write a Next.js component that uses useQueryState or useQueryStates and apply the nuqs best practices rules.

Frequently Asked Questions about nuqs

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I use useQueryState with typed values in Next.js?

Pass a typed parser like parseAsInteger or parseAsBoolean as the second argument to useQueryState so the state is typed instead of string | null. Add .withDefault(value) to eliminate null checks throughout the component tree.

How do I debounce search input URL updates with nuqs?

Since nuqs v2.5, pass limitUrlUpdates: debounce(300) in the parser's withOptions to debounce URL writes without manual setTimeout logic. For server-driven searches, combine it with shallow: false and useTransition so the server refetches once per typing pause.

Does nuqs work with React Router, Remix, or TanStack Router?

Yes, nuqs provides dedicated adapters for React Router v6/v7/v8, Remix, TanStack Router, and plain React via imports like nuqs/adapters/react-router/v7. Non-Next.js adapters also get key isolation, so hooks only re-render when their specific URL key changes.

Why does useQueryState fail or return undefined in my Next.js app?

The most common causes are a missing NuqsAdapter wrapper around the app, a missing 'use client' directive on components using hooks, or a Next.js version below 14.2 which nuqs v2 does not support. Verify the adapter setup and Next.js version first.

How do I access search params in Next.js Server Components with nuqs?

Use createSearchParamsCache or createLoader imported from nuqs/server, never from the main nuqs entry which carries a 'use client' directive. In Next.js 15+, searchParams is a Promise, so await the parse call before reading values or calling get() in nested components.

When should I use history push vs replace in nuqs?

Use history: 'push' for navigation-like state such as pagination, tabs, or modals so the back button undoes the change. Keep the default replace mode for ephemeral state like search text or sliders to avoid flooding browser history with one entry per keystroke.