Skip to main content

What are adapters?

Adapters are framework-specific integration layers that enable nuqs to work seamlessly across different React frameworks. They bridge the gap between nuqs’s core URL state management functionality and each framework’s unique routing and navigation systems.

Why are adapters needed?

Different React frameworks handle routing and URL updates in fundamentally different ways:
  • Next.js App Router uses React Server Components and navigation events
  • Next.js Pages Router relies on the next/router module
  • Plain React SPAs work directly with the browser’s History API
  • Remix and React Router have their own navigation paradigms
  • TanStack Router provides its own state management approach
Without adapters, nuqs would need to detect and handle these differences in every hook call, leading to a bloated bundle and maintenance nightmare. Adapters provide a clean abstraction that keeps the core library framework-agnostic.

How adapters work

Every adapter implements the AdapterInterface, which requires two core capabilities:
From packages/nuqs/src/adapters/lib/defs.ts:12-18

Available adapters

Next.js App Router

Supported versions: Next.js >=14.2.0. For older versions, install nuqs@^1.

Next.js Pages Router

Plain React (SPA)

For Vite, Create React App, or any React-based SPA:
The React adapter supports an optional prop for full-page navigation:
When enabled, setting shallow: false will trigger a full page reload instead of just a client-side navigation.

Remix

Supported versions: @remix-run/react@>=2

React Router v6

React Router v7

TanStack Router

TanStack Router support is experimental and does not yet cover TanStack Start.

Testing adapter

For unit testing components that use nuqs hooks:
From the README examples.

Creating custom adapters

You can create custom adapters for unsupported frameworks using the unstable_createAdapterProvider function:
Custom adapter APIs are marked as unstable_ and may change in future versions.

Adapter selection

The Next.js adapter automatically detects whether you’re using the app router or pages router at runtime:
From packages/nuqs/src/adapters/next.ts:6-20