From bd8cdba034b64db9e9d02faa3d0f68954cc04dcb Mon Sep 17 00:00:00 2001 From: Ivan Belikov Date: Fri, 20 Sep 2024 14:01:06 +0900 Subject: [PATCH] fix: nextjs router regression --- packages/core/package.json | 3 ++- packages/core/src/router.ts | 12 +++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/packages/core/package.json b/packages/core/package.json index 57c4fba..3f6a3be 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -16,7 +16,8 @@ "url-state", "search", "params", - "query" + "query", + "front-end" ], "description": "React hook for managing state in the URL", "dependencies": {}, diff --git a/packages/core/src/router.ts b/packages/core/src/router.ts index 64ba1d8..83e79f9 100644 --- a/packages/core/src/router.ts +++ b/packages/core/src/router.ts @@ -33,11 +33,13 @@ export class GenericRouter implements UrlStateRouter { push(href: string): void { // Use Next.js router if available // Next.js exposes a global object `window.next.router` with a `push` method for both /pages and /app routes - if (typeof window.next?.router?.push === 'function') { - window.next.router.push(href); - } else { - window.history.pushState({}, '', href); - } + // if (typeof window.next?.router?.push === 'function') { + // console.log('Next.js router is available'); + // window.next.router.push(href); + // } else { + // console.log('Next.js router is NOT available'); + window.history.pushState({}, '', href); + // } this.onSearchParamsChange(); }