Skip to content

Commit

Permalink
fix: nextjs router regression
Browse files Browse the repository at this point in the history
  • Loading branch information
wanjas committed Sep 20, 2024
1 parent 7526500 commit bd8cdba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@
"url-state",
"search",
"params",
"query"
"query",
"front-end"
],
"description": "React hook for managing state in the URL",
"dependencies": {},
Expand Down
12 changes: 7 additions & 5 deletions packages/core/src/router.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down

0 comments on commit bd8cdba

Please sign in to comment.