From ef75b2c681f5d81b1592a797f9664d1a1c6fe2ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Best?= Date: Mon, 15 Jan 2024 13:18:22 +0100 Subject: [PATCH] fix: Check for null `next` property on window (#456) Closes #454. --- packages/nuqs/src/update-queue.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/nuqs/src/update-queue.ts b/packages/nuqs/src/update-queue.ts index 3a813390..4837775b 100644 --- a/packages/nuqs/src/update-queue.ts +++ b/packages/nuqs/src/update-queue.ts @@ -160,7 +160,7 @@ function flushUpdateQueue(router: Router): [URLSearchParams, null | unknown] { // miss pushed history updates. // The router adapter imported from next/navigation also doesn't support // passing an asPath, causing issues in dynamic routes in the pages router. - const nextRouter = window.next.router + const nextRouter = window.next?.router const isPagesRouter = typeof nextRouter?.state?.asPath === 'string' if (isPagesRouter) { const url = renderURL(nextRouter.state.asPath.split('?')[0] ?? '', search)