Skip to content

Commit

Permalink
chore: Update list of supported versions
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Drop support for [email protected]

Due to a bug in the implementation of shallow routing (WHS),
14.0.3 required a special case for syncing
against external navigation.

In `[email protected]`, we're cleaning this up and requiring
a version of Next.js with bug-free support for
shallow routing (with or without experimental WHS
in 14.0.4, and with stabilised WHS in 14.0.5 onwards).
  • Loading branch information
franky47 committed Jan 17, 2024
1 parent f8a8d50 commit 9187252
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 24 deletions.
17 changes: 8 additions & 9 deletions .github/workflows/ci-cd.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,20 +24,19 @@ jobs:
base-path: [false, '/base']
window-history-support: [false]
next-version:
- '13.4'
- '13.4' # App router in GA
- '13.5'
- '14.0.1'
# 14.0.2 is not compatible due to a prefetch issue
- latest
- '14.0.5-canary.54' # WHS stabilised
# 14.0.3 is dropped due to a bug requiring WHS + syncing against uSP,
# which creates other problems under other versions of Next.js
- '14.0.4'
- latest # Currently 14.0.5
include:
# 14.0.3 requires the WHS flag
- next-version: '14.0.3'
# Add WHS tests in 14.0.4
- next-version: '14.0.4'
window-history-support: true
# Current latest is 14.0.4
- next-version: latest
window-history-support: true
- next-version: latest
- next-version: '14.0.4'
window-history-support: true
base-path: '/base'

Expand Down
8 changes: 8 additions & 0 deletions packages/docs/content/docs/migrations/v2.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ title: Migration guide to v2
description: How to update your code to use [email protected]
---

## Dropped support for `[email protected]`

It may seem weird to drop support for a single patch version, and keep it for
older versions, but this is due to a bug in shallow routing in Next.js 14.0.3
that was fixed in 14.0.4, and that became hard to work around without ugly hacks.

See #423 for context and a table of supported versions.

## ESM only

`[email protected]` is now an [ESM-only](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c)
Expand Down
2 changes: 1 addition & 1 deletion packages/nuqs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"prepack": "./scripts/prepack.sh"
},
"peerDependencies": {
"next": ">=13.4 <14.0.2 || ^14.0.3",
"next": ">=13.4 <14.0.2 || ^14.0.4",
"react": "^18.2.0"
},
"dependencies": {
Expand Down
1 change: 0 additions & 1 deletion packages/nuqs/src/update-queue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ export function scheduleFlushToURL(router: Router) {
declare global {
interface Window {
next: {
version: string
router?: NextRouter & {
state: {
asPath: string
Expand Down
13 changes: 0 additions & 13 deletions packages/nuqs/src/useQueryState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,19 +240,6 @@ export function useQueryState<T = string>(
initialSearchParams?.get(key) ?? null
)

React.useEffect(() => {
// This will be removed in v2 which will drop support for
// partially-functional shallow routing (14.0.2 and 14.0.3)
if (window.next.version !== '14.0.3') {
return
}
const value = initialSearchParams.get(key) ?? null
const state = value === null ? null : safeParse(parse, value, key)
debug('[nuqs `%s`] syncFromUseSearchParams %O', key, state)
stateRef.current = state
setInternalState(state)
}, [initialSearchParams?.get(key), key])

// Sync all hooks together & with external URL changes
React.useInsertionEffect(() => {
function updateInternalState(state: T | null) {
Expand Down

0 comments on commit 9187252

Please sign in to comment.