Skip to content

Conversation

@ValentinGurkov
Copy link
Contributor

@ValentinGurkov ValentinGurkov commented Nov 12, 2025

🎯 Changes

Hello 👋🏻

I’m in the process of migrating my app to Next.js 16, and I noticed that @tanstack/react-query-next-experimental was the only dependency blocking the upgrade. Coming from #9836, I went ahead and bumped the peer dependency version and ran some tests.

I haven’t encountered any issues so far, though my app currently uses the query client in only one area. I’d really appreciate it if others interested in this update could also try it out and share their results, so we can be certain that everything is fine and can move forward.

This is my first time opening a PR in any open source repo, so apologies if I don't get something right.

✅ Checklist

  • I have followed the steps in the Contributing guide.
  • I have tested this code locally with pnpm run test:pr.

🚀 Release Impact

  • This change affects published code, and I have generated a changeset.
  • This change is docs/CI/dev-only (no release).

Summary by CodeRabbit

  • New Features

    • Adds compatibility with Next.js 16.
  • Chores

    • Example projects updated to Next.js 16, React 19, and updated type declarations.
    • Adds a repository changeset recording a minor version update.
  • Build / Tooling

    • ESLint is now enforced during example builds.
    • Example scripts enable webpack and TypeScript config updated to include development type artifacts.
  • Cleanup

    • Removes explicit ambient Next.js type references and adds standard ignore rules for example artifacts.

@changeset-bot
Copy link

changeset-bot bot commented Nov 12, 2025

🦋 Changeset detected

Latest commit: 36f351e

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@tanstack/react-query-next-experimental Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 12, 2025

Walkthrough

Adds Next.js 16 support via a changeset and dependency bumps; upgrades an example to Next 16 / React 19, adjusts scripts and TypeScript includes, removes Next ambient type refs, re-enables ESLint during builds for the example, and adds a .gitignore for that example.

Changes

Cohort / File(s) Summary
Changeset documentation
/.changeset/old-plants-beg.md
New changeset recording a minor bump for @tanstack/react-query-next-experimental and a feat line for Next.js 16 support.
Package dependency updates
packages/react-query-next-experimental/package.json
peerDependencies.next extended to include ^16; devDependency next bumped from ^15.3.1 to ^16.0.1.
Example app dependencies & scripts
examples/react/nextjs-suspense-streaming/package.json
Bumped next to ^16.0.1, react/react-dom to ^19.0.0; updated @types/react/@types/react-dom; added --webpack flag to dev and build scripts.
Example Next types file
examples/react/nextjs-suspense-streaming/next-env.d.ts
Removed ambient Next.js /// <reference ... /> type declarations and the surrounding comment block.
Example Next config
examples/react/nextjs-suspense-streaming/next.config.js
Removed eslint.ignoreDuringBuilds: true so ESLint now runs during builds; typescript.ignoreBuildErrors and webpack customization remain.
Example TypeScript config
examples/react/nextjs-suspense-streaming/tsconfig.json
Reformatted include array and added .next/dev/types/**/*.ts to includes.
Example repo ignore
examples/react/nextjs-suspense-streaming/.gitignore
New .gitignore added listing common build/artifact and environment patterns to ignore.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant Dev as Developer
  participant Build as Next Build
  participant ESLint as ESLint
  participant TS as TypeScript

  Dev->>Build: run dev / build (scripts include --webpack)
  Build->>ESLint: invoke lint during build (previously ignored)
  alt ESLint passes
    ESLint-->>Build: OK
    Build->>TS: type-check / compile (includes .next/dev types)
    TS-->>Build: OK
    Build-->>Dev: serve or emit build artifacts
  else ESLint fails
    ESLint-->>Build: errors
    Build-->>Dev: fail build with lint errors
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Focus areas:
    • packages/react-query-next-experimental/package.json — peer/dev dependency changes for Next 16 compatibility.
    • examples/.../next.config.js — ESLint build behavior change.
    • examples/.../package.json and tsconfig.json — runtime and TS changes for Next 16 / React 19 and added .next types.

Possibly related PRs

Suggested reviewers

  • TkDodo

Poem

🐇 I hopped through package trees tonight,

Bumped Next and React to gleam so bright,
Took old refs down and woke the linter's song,
Examples danced and bundled all along,
A tiny hop — Next sixteen's bound for flight ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Next.js 16 support to @tanstack/react-query-next-experimental, matching the primary objective of the PR.
Description check ✅ Passed The description follows the template with all required sections completed: detailed explanation of changes and motivation, all checklist items checked off, and proper release impact classification with changeset confirmation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c7b9c25 and 36f351e.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • examples/react/nextjs-suspense-streaming/package.json (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • examples/react/nextjs-suspense-streaming/package.json

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between d46d35c and 6b7cca7.

📒 Files selected for processing (2)
  • .changeset/old-plants-beg.md (1 hunks)
  • packages/react-query-next-experimental/package.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-02T17:57:33.184Z
Learnt from: TkDodo
Repo: TanStack/query PR: 9612
File: packages/query-async-storage-persister/src/asyncThrottle.ts:0-0
Timestamp: 2025-09-02T17:57:33.184Z
Learning: When importing from tanstack/query-core in other TanStack Query packages like query-async-storage-persister, a workspace dependency "tanstack/query-core": "workspace:*" needs to be added to the package.json.

Applied to files:

  • packages/react-query-next-experimental/package.json
🔇 Additional comments (2)
packages/react-query-next-experimental/package.json (1)

59-70: Verify React 19.2 compatibility (shipped with Next.js 16).

Next.js 16 ships with React 19.2, which introduces new features like useEffectEvent() and <Activity/>. Ensure that the hydration utilities in react-query-next-experimental are compatible with these new React features and haven't been affected by any React 19.2 internal changes.

.changeset/old-plants-beg.md (1)

1-5: Changeset format is correct, but dependent on package.json validation.

The changeset entry is well-formed and the minor version bump is semantically appropriate for adding a new feature (Next.js 16 support). However, this changeset should only be merged after the peer dependency update in package.json has been validated against Next.js 16.

Merge this changeset only after confirming that react-query-next-experimental has been tested with Next.js 16 and all tests pass.

@ValentinGurkov
Copy link
Contributor Author

To better confirm the changes, I also updated the @tanstack/query-example-nextjs-suspense-streaming example and it works. The bundler is still webpack instead of the now-default turbopack.

Not related to the experimental package, but I created locally a react-next-16 integration package to test how the main package behaves with Next.js and the counter worked only if the bundler is webpack. I can also push that if you consider it helpful

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b7cca7 and 4bdc472.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (5)
  • examples/react/nextjs-suspense-streaming/next-env.d.ts (1 hunks)
  • examples/react/nextjs-suspense-streaming/next.config.js (0 hunks)
  • examples/react/nextjs-suspense-streaming/package.json (1 hunks)
  • examples/react/nextjs-suspense-streaming/tsconfig.json (2 hunks)
  • packages/react-query-next-experimental/package.json (1 hunks)
💤 Files with no reviewable changes (1)
  • examples/react/nextjs-suspense-streaming/next.config.js
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-09-02T17:57:33.184Z
Learnt from: TkDodo
Repo: TanStack/query PR: 9612
File: packages/query-async-storage-persister/src/asyncThrottle.ts:0-0
Timestamp: 2025-09-02T17:57:33.184Z
Learning: When importing from tanstack/query-core in other TanStack Query packages like query-async-storage-persister, a workspace dependency "tanstack/query-core": "workspace:*" needs to be added to the package.json.

Applied to files:

  • examples/react/nextjs-suspense-streaming/package.json
  • packages/react-query-next-experimental/package.json
🔇 Additional comments (5)
examples/react/nextjs-suspense-streaming/package.json (2)

6-7: Explain why webpack is being forced over Turbopack.

The addition of --webpack flags forces the webpack bundler instead of using Turbopack, which became stable for development in Next.js 15 and for production in Next.js 15.3. This bypasses the modern default bundler.

Is this due to a compatibility issue between TanStack Query and Turbopack, or is this intentional for testing purposes? Please clarify the reasoning, as this represents a regression to the legacy bundler.


14-20: Code is already React 19 compatible.

The verification confirms that the example does not use any deprecated React 18 APIs. The code uses modern patterns that are compatible with React 19:

  • React.Suspense is properly implemented and benefits from React 19 improvements
  • Props are typed with TypeScript (not deprecated propTypes)
  • No string refs or forwardRef usage
  • Client/Server components correctly marked with 'use client'
  • No deprecated form APIs (useFormState/useActionState)

The upgrade from React 18 to React 19 is safe for this example.

examples/react/nextjs-suspense-streaming/tsconfig.json (2)

19-19: Correct jsx transform for React 19.

The change from "preserve" to "react-jsx" enables the modern automatic JSX runtime, which is required for React 19. This aligns with the React 19 upgrade guide requirements.


31-32: Appropriate type includes for Next.js 16.

Adding .next/dev/types/**/*.ts ensures TypeScript includes Next.js 16's auto-generated development types, enabling features like typed routes.

packages/react-query-next-experimental/package.json (1)

62-68: Dev and peer dependencies aligned—manual Next.js 16 verification required.

The dependency update addresses the alignment concern: dev is now ^16.0.1 and peer includes ^16. However, this package has no runtime tests—only type checking and linting. Since the hydration utilities are sensitive to Next.js version differences, manual verification is necessary before merging:

  • Test with Next.js 16 locally (especially App Router, streaming, and Suspense behavior)
  • Verify hydration in both dev and production builds
  • Confirm no breaking changes to the hydration flow

@nx-cloud
Copy link

nx-cloud bot commented Nov 12, 2025

View your CI Pipeline Execution ↗ for commit 36f351e

Command Status Duration Result
nx affected --targets=test:sherif,test:knip,tes... ✅ Succeeded 4m 32s View ↗
nx run-many --target=build --exclude=examples/*... ✅ Succeeded 1m 23s View ↗

☁️ Nx Cloud last updated this comment at 2025-11-13 12:06:54 UTC

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 8da9c2e and fc39d77.

📒 Files selected for processing (1)
  • examples/react/nextjs-suspense-streaming/tsconfig.json (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-19T03:18:18.303Z
Learnt from: oscartbeaumont
Repo: TanStack/query PR: 9564
File: packages/solid-query-devtools/src/production.tsx:2-3
Timestamp: 2025-08-19T03:18:18.303Z
Learning: In the solid-query-devtools package, the codebase uses a pattern of type-only default imports combined with typeof for component type annotations (e.g., `import type SolidQueryDevtoolsComp from './devtools'` followed by `typeof SolidQueryDevtoolsComp`). This pattern is consistently used across index.tsx and production.tsx files, and the maintainers prefer consistency over changing this approach.

Applied to files:

  • examples/react/nextjs-suspense-streaming/tsconfig.json
🔇 Additional comments (3)
examples/react/nextjs-suspense-streaming/tsconfig.json (3)

15-15: Verify jsx setting aligns with Next.js 16 best practices.

The official @tsconfig/next base and Next.js documentation recommend "jsx": "preserve", as Next.js implements its own optimized JSX transform. The change to "react-jsx" deviates from the standard Next.js configuration pattern. While "react-jsx" works with React 17+, confirm this is intentional for this example and necessary for Next.js 16 support, or revert to the documented standard of "preserve".


23-29: LGTM: Include paths correctly reference Next.js generated types.

The .next/types/**/*.ts file is included in tsconfig.json so TypeScript compiler checks routes and provides feedback, and .next/dev/types/**/*.ts contains information about loaded environment variables for editor IntelliSense. These additions are appropriate for modern Next.js projects.


23-29: Include paths are correct for Next.js 16.

The addition of ".next/types//*.ts" (the documented recommended pattern) and ".next/dev/types//*.ts" (for the new dev/isolated build behavior in Next.js 16) ensures TypeScript correctly recognizes all generated type definitions. The configuration aligns with Next.js 16 best practices.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 13, 2025

More templates

@tanstack/angular-query-experimental

npm i https://pkg.pr.new/@tanstack/angular-query-experimental@9868

@tanstack/eslint-plugin-query

npm i https://pkg.pr.new/@tanstack/eslint-plugin-query@9868

@tanstack/query-async-storage-persister

npm i https://pkg.pr.new/@tanstack/query-async-storage-persister@9868

@tanstack/query-broadcast-client-experimental

npm i https://pkg.pr.new/@tanstack/query-broadcast-client-experimental@9868

@tanstack/query-core

npm i https://pkg.pr.new/@tanstack/query-core@9868

@tanstack/query-devtools

npm i https://pkg.pr.new/@tanstack/query-devtools@9868

@tanstack/query-persist-client-core

npm i https://pkg.pr.new/@tanstack/query-persist-client-core@9868

@tanstack/query-sync-storage-persister

npm i https://pkg.pr.new/@tanstack/query-sync-storage-persister@9868

@tanstack/react-query

npm i https://pkg.pr.new/@tanstack/react-query@9868

@tanstack/react-query-devtools

npm i https://pkg.pr.new/@tanstack/react-query-devtools@9868

@tanstack/react-query-next-experimental

npm i https://pkg.pr.new/@tanstack/react-query-next-experimental@9868

@tanstack/react-query-persist-client

npm i https://pkg.pr.new/@tanstack/react-query-persist-client@9868

@tanstack/solid-query

npm i https://pkg.pr.new/@tanstack/solid-query@9868

@tanstack/solid-query-devtools

npm i https://pkg.pr.new/@tanstack/solid-query-devtools@9868

@tanstack/solid-query-persist-client

npm i https://pkg.pr.new/@tanstack/solid-query-persist-client@9868

@tanstack/svelte-query

npm i https://pkg.pr.new/@tanstack/svelte-query@9868

@tanstack/svelte-query-devtools

npm i https://pkg.pr.new/@tanstack/svelte-query-devtools@9868

@tanstack/svelte-query-persist-client

npm i https://pkg.pr.new/@tanstack/svelte-query-persist-client@9868

@tanstack/vue-query

npm i https://pkg.pr.new/@tanstack/vue-query@9868

@tanstack/vue-query-devtools

npm i https://pkg.pr.new/@tanstack/vue-query-devtools@9868

commit: 36f351e

@ValentinGurkov
Copy link
Contributor Author

ValentinGurkov commented Nov 13, 2025

I saw that the PR tests failed due to the updated streaming example using React 19.2, whereas the rest of the repository uses 19.0, and it messes with the lock file. For now, I've reverted the React version in the example and the tests passed locally.

Sorry!

@TkDodo
Copy link
Collaborator

TkDodo commented Nov 13, 2025

after we merge this, do you want to make a separate PR that bumps everything to 19.2 ?

@ValentinGurkov
Copy link
Contributor Author

Sure, I can try and see how it goes

@codecov
Copy link

codecov bot commented Nov 13, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 45.78%. Comparing base (d46d35c) to head (36f351e).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #9868   +/-   ##
=======================================
  Coverage   45.78%   45.78%           
=======================================
  Files         200      200           
  Lines        8413     8413           
  Branches     1929     1921    -8     
=======================================
  Hits         3852     3852           
  Misses       4113     4113           
  Partials      448      448           
Components Coverage Δ
@tanstack/angular-query-experimental 93.85% <ø> (ø)
@tanstack/eslint-plugin-query 83.59% <ø> (ø)
@tanstack/query-async-storage-persister 43.85% <ø> (ø)
@tanstack/query-broadcast-client-experimental 24.39% <ø> (ø)
@tanstack/query-codemods 0.00% <ø> (ø)
@tanstack/query-core 97.38% <ø> (ø)
@tanstack/query-devtools 3.48% <ø> (ø)
@tanstack/query-persist-client-core 80.00% <ø> (ø)
@tanstack/query-sync-storage-persister 84.61% <ø> (ø)
@tanstack/query-test-utils 77.77% <ø> (ø)
@tanstack/react-query 96.01% <ø> (ø)
@tanstack/react-query-devtools 10.00% <ø> (ø)
@tanstack/react-query-next-experimental ∅ <ø> (∅)
@tanstack/react-query-persist-client 100.00% <ø> (ø)
@tanstack/solid-query 77.81% <ø> (ø)
@tanstack/solid-query-devtools 61.90% <ø> (ø)
@tanstack/solid-query-persist-client 100.00% <ø> (ø)
@tanstack/svelte-query ∅ <ø> (∅)
@tanstack/svelte-query-devtools ∅ <ø> (∅)
@tanstack/svelte-query-persist-client ∅ <ø> (∅)
@tanstack/vue-query 71.28% <ø> (ø)
@tanstack/vue-query-devtools ∅ <ø> (∅)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@TkDodo TkDodo merged commit 7ed2d16 into TanStack:main Nov 13, 2025
9 checks passed
@github-actions github-actions bot mentioned this pull request Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants