Skip to content

fix(examples): replace deprecated 'isServer' with 'environmentManager.isServer()' in remaining Next.js examples#10860

Merged
TkDodo merged 1 commit into
TanStack:mainfrom
spiderocious:fix/examples-isserver-environment-manager
Jun 2, 2026
Merged

fix(examples): replace deprecated 'isServer' with 'environmentManager.isServer()' in remaining Next.js examples#10860
TkDodo merged 1 commit into
TanStack:mainfrom
spiderocious:fix/examples-isserver-environment-manager

Conversation

@spiderocious
Copy link
Copy Markdown
Contributor

@spiderocious spiderocious commented Jun 2, 2026

🎯 Changes

Continues the isServerenvironmentManager.isServer() migration kicked off by #10199 and continued through:

Two example files were missed by #10858 and still import the deprecated isServer export. This PR migrates them:

  • examples/react/nextjs-app-prefetching/app/get-query-client.ts
  • examples/react/nextjs-suspense-streaming/src/app/providers.tsx

Without these updates, users copy-pasting the Next.js example snippets into their own projects pull in the deprecated isServer export and see the @deprecated warning in their IDE.

No behavior change — environmentManager.isServer() performs the same check by default while allowing host environments to override it.

✅ 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

Release Notes

  • Refactor
    • Updated NextJS examples to use the new environment detection API from @tanstack/react-query. Both the app prefetching and suspense streaming examples now utilize the recommended approach for distinguishing between server and browser runtime contexts. This change improves code consistency, ensures more reliable behavior across deployment scenarios, and aligns with current React Query best practices.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4cd1c9c9-90d0-4c0c-8f05-cace3aeb2a56

📥 Commits

Reviewing files that changed from the base of the PR and between 0bc0a88 and b21b51a.

📒 Files selected for processing (2)
  • examples/react/nextjs-app-prefetching/app/get-query-client.ts
  • examples/react/nextjs-suspense-streaming/src/app/providers.tsx

📝 Walkthrough

Walkthrough

Two Next.js example files update environment detection by replacing the deprecated isServer import and static check with environmentManager.isServer() method calls. Both examples maintain their existing query-client creation strategy: server requests create fresh instances, browser requests reuse a singleton.

Changes

Environment Detection Migration to environmentManager

Layer / File(s) Summary
QueryClient setup environment check migration
examples/react/nextjs-app-prefetching/app/get-query-client.ts, examples/react/nextjs-suspense-streaming/src/app/providers.tsx
Both example files swap isServer import for environmentManager, and update server-vs-browser branching from if (isServer) to if (environmentManager.isServer()) inside their getQueryClient() functions.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related issues

Possibly related PRs

  • TanStack/query#10826: Both PRs update server-environment detection by replacing the deprecated isServer check with environmentManager.isServer() in the relevant query/client setup logic (React examples vs the Vue plugin).
  • TanStack/query#10858: Both PRs perform the same Next.js migration by replacing @tanstack/react-query's deprecated isServer usage with environmentManager.isServer() in React Query environment-detection logic (query-client creation in providers and server checks elsewhere).

Suggested reviewers

  • TkDodo

Poem

🐰 The server knows itself by asking now,
No static flags that bowed to isServer anew,
environmentManager whispers the truth—
A fresher check for queries' proof! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: replacing deprecated 'isServer' with 'environmentManager.isServer()' in specific Next.js example files.
Description check ✅ Passed The description follows the template structure with complete 🎯 Changes section explaining the migration, all checklist items addressed, and clear 🚀 Release Impact assessment.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

@spiderocious spiderocious marked this pull request as ready for review June 2, 2026 11:41
@TkDodo TkDodo merged commit 2faff25 into TanStack:main Jun 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants