diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 49f53c0b..3ff3517e 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -30,6 +30,10 @@ jobs: # 14.0.2 is not compatible due to a prefetch issue - latest include: + # 14.0.3 requires the WHS flag + - next-version: '14.0.3' + window-history-support: true + # Current latest is 14.0.4 - next-version: latest window-history-support: true - next-version: latest diff --git a/packages/e2e/cypress.config.ts b/packages/e2e/cypress.config.ts index a37be802..c452562c 100644 --- a/packages/e2e/cypress.config.ts +++ b/packages/e2e/cypress.config.ts @@ -30,5 +30,8 @@ function supportsWHS() { const pkgPath = new URL('./package.json', import.meta.url) const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8')) const nextVersion: string = pkg.dependencies.next - return semver.gte(nextVersion, '14.0.3-canary.6') + return ( + semver.gte(nextVersion, '14.0.3-canary.6') && + semver.lt(nextVersion, '14.0.5-canary.54') + ) } diff --git a/packages/nuqs/src/useQueryState.ts b/packages/nuqs/src/useQueryState.ts index 1ce278d5..d9e7989f 100644 --- a/packages/nuqs/src/useQueryState.ts +++ b/packages/nuqs/src/useQueryState.ts @@ -240,15 +240,13 @@ export function useQueryState( initialSearchParams?.get(key) ?? null ) - if (process.env.__NEXT_WINDOW_HISTORY_SUPPORT) { - React.useEffect(() => { - 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]) - } + React.useEffect(() => { + 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(() => {