Nuqs

作者 pproencacf93c57cac89无许可证215 个星标收录于 2026年10月8日更新于 2026年10月8日仓库7周前更新

nuqs (type-safe URL query state) best practices for Next.js and other React frameworks. This skill should be used when writing, reviewing, or refactoring code that uses nuqs for URL state management. Triggers on tasks involving useQueryState, useQueryStates, search params, URL state, query parameters, nuqs parsers, limitUrlUpdates, Standard Schema, NuqsAdapter, or Next.js routing with state.

AI 生成的概览

在 Next.js 和 React 应用中使用 nuqs 类型安全 URL 查询状态的指南。

功能
该技能提供一套按优先级排列的 nuqs URL 查询状态最佳实践规则,适用于 Next.js 及其他 React 框架。内容涵盖解析器配置、适配器设置、状态管理、服务端集成、性能、历史与导航、调试以及高级模式。每条规则都有独立的参考文件,包含说明和代码示例,AGENTS.md 中还有一份汇总指南。
适用场景
在编写、审查或重构使用 nuqs 进行 URL 状态管理的代码时使用,例如涉及 useQueryState、useQueryStates、搜索参数或 NuqsAdapter 的任务。也适用于配置解析器、将 URL 状态与服务端组件集成,或优化 URL 更新性能的场景。
运行要求
不附带脚本,仅为说明文档和参考文件。假定项目使用 nuqs 与 Next.js 或其他 React 框架,内容覆盖 nuqs v2.5 至 v2.9。

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

PriorityCategoryImpactPrefix
1Parser ConfigurationCRITICALparser-
2Adapter & SetupCRITICALsetup-
3State ManagementHIGHstate-
4Server IntegrationHIGHserver-
5Performance OptimizationMEDIUMperf-
6History & NavigationMEDIUMhistory-
7Debugging & TestingLOW-MEDIUMdebug-
8Advanced PatternsLOWadvanced-

Quick Reference

1. Parser Configuration (CRITICAL)

  • parser-use-typed-parsers [blocked] — Use typed parsers for non-string values
  • parser-with-default [blocked] — Use withDefault for non-nullable state
  • parser-enum-validation [blocked] — Use enum parsers for constrained values
  • parser-array-format [blocked] — Choose correct array parser format
  • parser-json-validation [blocked] — Validate JSON parser input
  • parser-date-format [blocked] — Select appropriate date parser
  • parser-index-offset [blocked] — Use parseAsIndex for 1-based URL display

2. Adapter & Setup (CRITICAL)

  • setup-nuqs-adapter [blocked] — Wrap app with NuqsAdapter
  • setup-use-client [blocked] — Add 'use client' directive for hooks
  • setup-import-server [blocked] — Import server utilities from nuqs/server
  • setup-nextjs-version [blocked] — Ensure compatible Next.js version
  • setup-shared-parsers [blocked] — Define shared parsers in dedicated file
  • setup-default-options [blocked] — Configure app-wide defaults on NuqsAdapter (v2.5+)

3. State Management (HIGH)

  • state-use-query-states [blocked] — Use useQueryStates for related parameters
  • state-clear-with-null [blocked] — Clear URL parameters with null
  • state-avoid-derived [blocked] — Avoid derived state from URL parameters
  • state-options-inheritance [blocked] — Use withOptions for parser-level configuration
  • state-setter-return [blocked] — Use setter return value for URL access
  • state-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 Components
  • server-shallow-false [blocked] — Use shallow:false to trigger server re-renders
  • server-use-transition [blocked] — Integrate useTransition for loading states
  • server-parse-before-get [blocked] — Call parse() before get() in Server Components
  • server-next15-async [blocked] — Handle async searchParams in Next.js 15+

5. Performance Optimization (MEDIUM)

  • perf-throttle-updates [blocked] — Throttle rapid URL updates with limitUrlUpdates
  • perf-debounce-search [blocked] — Debounce search input with built-in limitUrlUpdates
  • perf-clear-on-default [blocked] — Use clearOnDefault for clean URLs
  • perf-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:replace
  • history-scroll-behavior [blocked] — Control scroll behavior on URL changes

7. Debugging & Testing (LOW-MEDIUM)

  • debug-enable-logging [blocked] — Enable debug logging for troubleshooting
  • debug-testing [blocked] — Test components with URL state

8. Advanced Patterns (LOW)

  • advanced-custom-parsers [blocked] — Create custom parsers for complex types
  • advanced-url-keys [blocked] — Use urlKeys for shorter URLs
  • advanced-eq-function [blocked] — Implement eq function for object parsers
  • advanced-framework-adapters [blocked] — Use framework-specific adapters
  • advanced-process-url-search-params [blocked] — Canonicalize URL shape with processUrlSearchParams (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

Reference Files

FileDescription
AGENTS.md [blocked]Complete compiled guide with all rules
references/_sections.md [blocked]Category definitions and ordering
assets/templates/_template.md [blocked]Template for new rules
metadata.json [blocked]Version and reference information

来源与署名

来源:pproenca/dot-skills位于skills/.curated/nuqs提交cf93c57

许可证: 无许可证

内容归原作者所有。SourceWeft 从公开仓库中收录这些内容。

举报或申请下架