nuqs icon indicating copy to clipboard operation
nuqs copied to clipboard

Nuqs not detecting adapter in Next.js 16 App Router setup

Open yWilliamLima opened this issue 11 months ago • 3 comments

Context

nuqs version:

"nuqs": "2.8.5"

Framework used:

  • ✅ Next.js (app router)

Framework version:

"next": "16.0.8"

Description

When using NuqsAdapter inside the root layout of a Next.js App Router project, I get the following error:

⨯ Error: [nuqs] nuqs requires an adapter to work with your framework.

The adapter is set up exactly as shown in the documentation, but the error keeps appearing even though NuqsAdapter wraps the whole application.

Reproduction

Relevant code

import { NuqsAdapter } from 'nuqs/adapters/next/app'

export default function Layout({ children }) {
  return (
    <html lang="pt-BR" suppressHydrationWarning>
      <head />
      <body>
        <NuqsAdapter>
          <Providers>
            {children}
            <Toaster richColors />
          </Providers>
        </NuqsAdapter>
      </body>
    </html>
  )
}

Steps to reproduce

  1. Create a Next.js v16 project using the App Router.
  2. Install [email protected].
  3. Add NuqsAdapter to the root layout as shown above.
  4. Run npm run dev or next dev.
  5. The error appears immediately in the terminal or when loading the page.

yWilliamLima avatar Dec 10 '25 16:12 yWilliamLima

I can't reproduce it with a fresh pnpm create next-app, could you provide a minimal example where this fails in your case please?

franky47 avatar Dec 10 '25 16:12 franky47

I have a Turborepo setup with a shared components package. Inside that package, I installed nuqs and use it in some components. These components are only consumed inside my main app, which has the proper layout and nuqs adapter configured.

The issue is that the components package uses nuqs, but since it isn’t a web app or a Next.js page, it doesn’t have its own nuqs setup. Because of that, errors occur when the components that rely on nuqs are imported, even though the main app properly provides the adapter where they are ultimately rendered.

This issue started happening after version 2.8.3 of nuqs; if I downgrade back to 2.8.3, everything works as expected.

yWilliamLima avatar Dec 10 '25 20:12 yWilliamLima

Ah I see, then it sounds like #798 (different versions of nuqs being resolved across packages, leading to the Context reference being different).

What package manager are you using? There's nothing specific about the Context provider in 2.8.3 that makes it relevant, it could be a difference in how the package versions are resolved in your lockfile.

franky47 avatar Dec 10 '25 21:12 franky47