Skip to content

fix: nuqs provider#354

Closed
Desmenez wants to merge 2 commits intosoftnetics:mainfrom
Desmenez:napatpon/fix-nuqs-provider
Closed

fix: nuqs provider#354
Desmenez wants to merge 2 commits intosoftnetics:mainfrom
Desmenez:napatpon/fix-nuqs-provider

Conversation

@Desmenez
Copy link
Copy Markdown
Contributor

@Desmenez Desmenez commented Apr 24, 2026

Why did you create this PR

image

Problem

Collection list UI and related hooks called nuqs directly (useSearch, usePagination, useSort). In a Next.js App Router consumer, those hooks require a valid nuqs adapter boundary. When components render outside that boundary (or before the adapter is available), runtime throws [nuqs] NUQS-404.

Solution

  • Introduced TableStatesContextProvider: a pure React context provider that accepts search / pagination / sort state and setters via props. It does not call nuqs, so table UI can render without NuqsAdapter as long as state is supplied.
  • Kept TableStatesProvider as the legacy, backward-compatible API: it still wires state through the existing nuqs hooks and passes them into TableStatesContextProvider.
  • Updated list components and the list query hook to read search / pagination / sort from useTableStatesContext() instead of calling nuqs hooks directly (CollectionListSearch, CollectionListPagination, useCollectionListQuery).
  • Added Vitest coverage: one test renders under TableStatesContextProvider without NuqsAdapter (no throw), and one test asserts TableStatesProvider still exposes the expected state when nuqs hooks are mocked.

Compatibility / risk

  • Public names preserved (TableStatesProvider, useTableStatesContext); new export: TableStatesContextProvider (+ its props type).
  • Consumers using TableStatesProvider unchanged; any direct nuqs usage elsewhere in the app can still throw if not under the correct adapter—this change addresses the lib’s table/list path specifically.

Screenshots / Recordings

Checklist

  • Self-reviewed your code
  • Wrote coverage tests
  • Added screenshots or recordings if applicable

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 24, 2026

🦋 Changeset detected

Latest commit: 193ace7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 8 packages
Name Type
@genseki/react Patch
@example/erp Patch
@example/ui-playground Patch
@genseki/next Patch
@genseki/plugins Patch
@genseki/prisma-generator Patch
@genseki/react-query Patch
@genseki/rest Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@Desmenez Desmenez closed this Apr 24, 2026
@Desmenez Desmenez deleted the napatpon/fix-nuqs-provider branch April 24, 2026 11:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant