Nuqs not detecting adapter in Next.js 16 App Router setup
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
- Create a Next.js v16 project using the App Router.
- Install
[email protected]. - Add
NuqsAdapterto the root layout as shown above. - Run
npm run devornext dev. - The error appears immediately in the terminal or when loading the page.
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?
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.
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.