Skip to main content
The TanStack Router adapter enables nuqs to work with TanStack Router v1 applications.
TanStack Router support is experimental and does not yet cover TanStack Start (the SSR framework).

Installation

1

Install nuqs

Install nuqs in your TanStack Router project:
2

Add the adapter to your root route

Wrap your app with NuqsAdapter in your root route component:
src/routes/__root.tsx
The NuqsAdapter should wrap the <Outlet /> component to provide context to all routes.
3

Use nuqs hooks in your route components

Now you can use useQueryState and useQueryStates in any route component:
src/routes/search.tsx

Version Requirements

  • @tanstack/react-router: ^1
  • React: >=18.2.0 or ^19.0.0-0

Features

Integration with TanStack Router

The adapter uses TanStack Router’s native useLocation() and useRouter() hooks, ensuring seamless integration with TanStack Router’s navigation system.

Automatic Type Handling

TanStack Router JSON-parses objects in search params by default. The nuqs adapter automatically handles this:
The adapter respects nuqs history and scroll options:
These map to TanStack Router’s replace and resetScroll options.

Optimized Performance

The adapter has a rateLimitFactor of 1, meaning it’s optimized for TanStack Router’s navigation performance characteristics.

How It Works

The TanStack Router adapter:
  1. Uses useLocation() to read search params from the route state
  2. Filters and watches only the keys used by nuqs hooks
  3. Converts TanStack Router’s search object format to URLSearchParams
  4. Uses navigate() to update the URL with custom encoding
  5. Wraps navigation in startTransition for scroll restoration support
  6. Handles TanStack Router’s object serialization automatically

Examples

Search with Results

src/routes/search.tsx

Filters with Multiple States

src/routes/products.tsx

Pagination with History

src/routes/blog.tsx

Working with TanStack Router Search Params

Mixing nuqs with TanStack Router’s Search Params

You can use nuqs alongside TanStack Router’s built-in search param validation:
src/routes/products.tsx

Limitations

TanStack Start (SSR) Not Supported

The current adapter is designed for client-side TanStack Router applications. Support for TanStack Start (the SSR framework) is not yet available.

JSON Object Handling

TanStack Router automatically JSON-parses objects in search params. When using parseAsJson, the adapter re-stringifies these objects to ensure compatibility. This adds a small overhead but maintains consistency with other nuqs adapters.

Troubleshooting

Search params not updating

Ensure:
  1. The NuqsAdapter is placed in your root route and wraps <Outlet />
  2. Your route components are properly nested under the root route
  3. You’re using TanStack Router v1 or later

Type errors with search params

If you’re using TanStack Router’s search param validation and getting type conflicts:

Adapter not found error

Make sure you’re importing from the correct path: