Community nuqs Best Practices for Next.js & React
Comprehensive guide for type-safe URL query state management with nuqs across Next.js, React Router, TanStack Router, Remix, and plain React. Covers nuqs v2.5–v2.9 features. Contains 39 rules across 8 categories, prioritized by impact to guide code generation, refactoring, and code review.
When to Apply
Reference these guidelines when:
- Implementing URL-based state with nuqs
- Setting up nuqs in a Next.js or React Router project
- Configuring parsers for URL parameters
- Integrating URL state with Server Components
- Optimizing URL update performance (
limitUrlUpdates, key isolation) - Sharing parser definitions with tRPC / TanStack Router / forms via Standard Schema
- Debugging nuqs-related issues
Rule Categories by Priority
Quick Reference
1. Parser Configuration (CRITICAL)
parser-use-typed-parsers[blocked] — Use typed parsers for non-string valuesparser-with-default[blocked] — Use withDefault for non-nullable stateparser-enum-validation[blocked] — Use enum parsers for constrained valuesparser-array-format[blocked] — Choose correct array parser formatparser-json-validation[blocked] — Validate JSON parser inputparser-date-format[blocked] — Select appropriate date parserparser-index-offset[blocked] — Use parseAsIndex for 1-based URL display
2. Adapter & Setup (CRITICAL)
setup-nuqs-adapter[blocked] — Wrap app with NuqsAdaptersetup-use-client[blocked] — Add 'use client' directive for hookssetup-import-server[blocked] — Import server utilities from nuqs/serversetup-nextjs-version[blocked] — Ensure compatible Next.js versionsetup-shared-parsers[blocked] — Define shared parsers in dedicated filesetup-default-options[blocked] — Configure app-wide defaults on NuqsAdapter (v2.5+)
3. State Management (HIGH)
state-use-query-states[blocked] — Use useQueryStates for related parametersstate-clear-with-null[blocked] — Clear URL parameters with nullstate-avoid-derived[blocked] — Avoid derived state from URL parametersstate-options-inheritance[blocked] — Use withOptions for parser-level configurationstate-setter-return[blocked] — Use setter return value for URL accessstate-standard-schema[blocked] — Use Standard Schema for cross-library validation (v2.5+)
4. Server Integration (HIGH)
server-search-params-cache[blocked] — Use createSearchParamsCache (or createLoader) for Server Componentsserver-shallow-false[blocked] — Use shallow:false to trigger server re-rendersserver-use-transition[blocked] — Integrate useTransition for loading statesserver-parse-before-get[blocked] — Call parse() before get() in Server Componentsserver-next15-async[blocked] — Handle async searchParams in Next.js 15+
5. Performance Optimization (MEDIUM)
perf-throttle-updates[blocked] — Throttle rapid URL updates withlimitUrlUpdatesperf-debounce-search[blocked] — Debounce search input with built-inlimitUrlUpdatesperf-clear-on-default[blocked] — Use clearOnDefault for clean URLsperf-avoid-rerender[blocked] — Memoize components using URL state (Next.js)perf-key-isolation[blocked] — Rely on key isolation outside Next.js (v2.5+)perf-serialize-utility[blocked] — Use createSerializer for link URLs
6. History & Navigation (MEDIUM)
history-push-navigation[blocked] — Choose history:push vs history:replacehistory-scroll-behavior[blocked] — Control scroll behavior on URL changes
7. Debugging & Testing (LOW-MEDIUM)
debug-enable-logging[blocked] — Enable debug logging for troubleshootingdebug-testing[blocked] — Test components with URL state
8. Advanced Patterns (LOW)
advanced-custom-parsers[blocked] — Create custom parsers for complex typesadvanced-url-keys[blocked] — Use urlKeys for shorter URLsadvanced-eq-function[blocked] — Implement eq function for object parsersadvanced-framework-adapters[blocked] — Use framework-specific adaptersadvanced-process-url-search-params[blocked] — Canonicalize URL shape withprocessUrlSearchParams(v2.6+)
How to Use
Read individual reference files for detailed explanations and code examples:
- Section definitions [blocked] — Category structure and impact levels
- Rule template [blocked] — Template for adding new rules


