Nuqs

pproenca/dot-skills/skills/.curated/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 從公開儲存庫中收錄這些內容。

檢舉或申請下架