Skip to content

Conversation

@manudeli
Copy link
Member

@manudeli manudeli commented Jan 12, 2026

Suggested by @gs18004

support infiniteQueryOptions for QueriesHydration

PR Checklist

  • I did below actions if need
  1. I read the Contributing Guide
  2. I added documents and tests.

- Enhanced QueriesHydration to accept infiniteQueryOptions alongside regular query options.
- Added tests to verify hydration and SSR behavior for infinite queries, including error handling and state dehydration.
- Updated type definitions to reflect the new query structure.

Co-authored-by: Yoomin Kang <[email protected]>
@changeset-bot
Copy link

changeset-bot bot commented Jan 12, 2026

🦋 Changeset detected

Latest commit: f47cc33

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

This PR includes changesets to release 7 packages
Name Type
@suspensive/react-query-4 Minor
@suspensive/react-query-5 Minor
@suspensive/react Minor
@suspensive/react-dom Minor
@suspensive/react-query Minor
@suspensive/jotai Minor
@suspensive/codemods 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

@coauthors
Copy link

coauthors bot commented Jan 12, 2026

@vercel
Copy link
Contributor

vercel bot commented Jan 12, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
suspensive-next-streaming-react-query Ready Ready Preview, Comment Jan 13, 2026 9:46am
v2.suspensive.org Ready Ready Preview, Comment Jan 13, 2026 9:46am
v3.suspensive.org Ready Ready Preview, Comment Jan 13, 2026 9:46am
visualization.suspensive.org Ready Ready Preview, Comment Jan 13, 2026 9:46am

@github-actions
Copy link
Contributor

github-actions bot commented Jan 12, 2026

Size Change: +112 B (+0.13%)

Total Size: 88.7 kB

Filename Size Change
packages/react-query-4/dist/index.cjs 541 B -1 B (-0.18%)
packages/react-query-4/dist/index.mjs 453 B +3 B (+0.67%)
packages/react-query-4/dist/QueriesHydration-********.cjs 1.63 kB +28 B (+1.75%)
packages/react-query-4/dist/QueriesHydration-********.mjs 1.54 kB +25 B (+1.65%)
packages/react-query-5/dist/QueriesHydration-********.cjs 1.64 kB +30 B (+1.87%)
packages/react-query-5/dist/QueriesHydration-********.mjs 1.55 kB +27 B (+1.77%)
ℹ️ View Unchanged
Filename Size
packages/jotai/dist/Atom-********.cjs 328 B
packages/jotai/dist/Atom-********.mjs 263 B
packages/jotai/dist/Atom.cjs 93 B
packages/jotai/dist/Atom.mjs 87 B
packages/jotai/dist/AtomValue-********.cjs 315 B
packages/jotai/dist/AtomValue-********.mjs 247 B
packages/jotai/dist/AtomValue.cjs 99 B
packages/jotai/dist/AtomValue.mjs 93 B
packages/jotai/dist/index.cjs 150 B
packages/jotai/dist/index.mjs 133 B
packages/jotai/dist/SetAtom-********.cjs 313 B
packages/jotai/dist/SetAtom-********.mjs 246 B
packages/jotai/dist/SetAtom.cjs 97 B
packages/jotai/dist/SetAtom.mjs 91 B
packages/next/dist/index.cjs 256 B
packages/next/dist/index.mjs 250 B
packages/next/dist/react-******.cjs 217 B
packages/next/dist/react-******.mjs 213 B
packages/react-dom/dist/FadeIn-********.cjs 471 B
packages/react-dom/dist/FadeIn-********.mjs 402 B
packages/react-dom/dist/FadeIn.cjs 96 B
packages/react-dom/dist/FadeIn.mjs 90 B
packages/react-dom/dist/index.cjs 176 B
packages/react-dom/dist/index.mjs 153 B
packages/react-dom/dist/InView-********.cjs 733 B
packages/react-dom/dist/InView-********.mjs 670 B
packages/react-dom/dist/InView.cjs 96 B
packages/react-dom/dist/InView.mjs 90 B
packages/react-dom/dist/useFadeIn-********.cjs 496 B
packages/react-dom/dist/useFadeIn-********.mjs 432 B
packages/react-dom/dist/useFadeIn.cjs 99 B
packages/react-dom/dist/useFadeIn.mjs 93 B
packages/react-dom/dist/useInView-********.cjs 1.66 kB
packages/react-dom/dist/useInView-********.mjs 1.61 kB
packages/react-dom/dist/useInView.cjs 99 B
packages/react-dom/dist/useInView.mjs 93 B
packages/react-query-4/dist/ClientOnly-********.cjs 394 B
packages/react-query-4/dist/ClientOnly-********.mjs 323 B
packages/react-query-4/dist/createGetQueryClient-********.cjs 1.08 kB
packages/react-query-4/dist/createGetQueryClient-********.mjs 1 kB
packages/react-query-4/dist/createGetQueryClient.cjs 98 B
packages/react-query-4/dist/createGetQueryClient.mjs 91 B
packages/react-query-4/dist/infiniteQueryOptions-********.cjs 375 B
packages/react-query-4/dist/infiniteQueryOptions-********.mjs 302 B
packages/react-query-4/dist/infiniteQueryOptions.cjs 98 B
packages/react-query-4/dist/infiniteQueryOptions.mjs 91 B
packages/react-query-4/dist/IsFetching-********.cjs 347 B
packages/react-query-4/dist/IsFetching-********.mjs 266 B
packages/react-query-4/dist/IsFetching.cjs 102 B
packages/react-query-4/dist/IsFetching.mjs 96 B
packages/react-query-4/dist/Mutation-********.cjs 393 B
packages/react-query-4/dist/Mutation-********.mjs 315 B
packages/react-query-4/dist/Mutation.cjs 100 B
packages/react-query-4/dist/Mutation.mjs 94 B
packages/react-query-4/dist/mutationOptions-********.cjs 203 B
packages/react-query-4/dist/mutationOptions-********.mjs 147 B
packages/react-query-4/dist/mutationOptions.cjs 90 B
packages/react-query-4/dist/mutationOptions.mjs 84 B
packages/react-query-4/dist/objectSpread2-********.cjs 799 B
packages/react-query-4/dist/objectSpread2-********.mjs 767 B
packages/react-query-4/dist/objectWithoutProperties-********.cjs 406 B
packages/react-query-4/dist/objectWithoutProperties-********.mjs 366 B
packages/react-query-4/dist/PrefetchInfiniteQuery-********.cjs 476 B
packages/react-query-4/dist/PrefetchInfiniteQuery-********.mjs 407 B
packages/react-query-4/dist/PrefetchInfiniteQuery.cjs 114 B
packages/react-query-4/dist/PrefetchInfiniteQuery.mjs 107 B
packages/react-query-4/dist/PrefetchQuery-********.cjs 463 B
packages/react-query-4/dist/PrefetchQuery-********.mjs 396 B
packages/react-query-4/dist/PrefetchQuery.cjs 105 B
packages/react-query-4/dist/PrefetchQuery.mjs 99 B
packages/react-query-4/dist/QueriesHydration.cjs 93 B
packages/react-query-4/dist/QueriesHydration.mjs 87 B
packages/react-query-4/dist/QueryClientConsumer-********.cjs 356 B
packages/react-query-4/dist/QueryClientConsumer-********.mjs 285 B
packages/react-query-4/dist/QueryClientConsumer.cjs 109 B
packages/react-query-4/dist/QueryClientConsumer.mjs 102 B
packages/react-query-4/dist/queryOptions-********.cjs 366 B
packages/react-query-4/dist/queryOptions-********.mjs 295 B
packages/react-query-4/dist/queryOptions.cjs 89 B
packages/react-query-4/dist/queryOptions.mjs 83 B
packages/react-query-4/dist/SuspenseInfiniteQuery-********.cjs 651 B
packages/react-query-4/dist/SuspenseInfiniteQuery-********.mjs 566 B
packages/react-query-4/dist/SuspenseInfiniteQuery.cjs 114 B
packages/react-query-4/dist/SuspenseInfiniteQuery.mjs 107 B
packages/react-query-4/dist/SuspenseQueries-********.cjs 572 B
packages/react-query-4/dist/SuspenseQueries-********.mjs 487 B
packages/react-query-4/dist/SuspenseQueries.cjs 107 B
packages/react-query-4/dist/SuspenseQueries.mjs 101 B
packages/react-query-4/dist/SuspenseQuery-********.cjs 638 B
packages/react-query-4/dist/SuspenseQuery-********.mjs 553 B
packages/react-query-4/dist/SuspenseQuery.cjs 105 B
packages/react-query-4/dist/SuspenseQuery.mjs 99 B
packages/react-query-4/dist/usePrefetchInfiniteQuery-********.cjs 464 B
packages/react-query-4/dist/usePrefetchInfiniteQuery-********.mjs 400 B
packages/react-query-4/dist/usePrefetchInfiniteQuery.cjs 117 B
packages/react-query-4/dist/usePrefetchInfiniteQuery.mjs 110 B
packages/react-query-4/dist/usePrefetchQuery-********.cjs 455 B
packages/react-query-4/dist/usePrefetchQuery-********.mjs 392 B
packages/react-query-4/dist/usePrefetchQuery.cjs 108 B
packages/react-query-4/dist/usePrefetchQuery.mjs 102 B
packages/react-query-4/dist/useSuspenseInfiniteQuery-********.cjs 380 B
packages/react-query-4/dist/useSuspenseInfiniteQuery-********.mjs 305 B
packages/react-query-4/dist/useSuspenseInfiniteQuery.cjs 117 B
packages/react-query-4/dist/useSuspenseInfiniteQuery.mjs 110 B
packages/react-query-4/dist/useSuspenseQueries-********.cjs 375 B
packages/react-query-4/dist/useSuspenseQueries-********.mjs 300 B
packages/react-query-4/dist/useSuspenseQueries.cjs 111 B
packages/react-query-4/dist/useSuspenseQueries.mjs 104 B
packages/react-query-4/dist/useSuspenseQuery-********.cjs 369 B
packages/react-query-4/dist/useSuspenseQuery-********.mjs 298 B
packages/react-query-4/dist/useSuspenseQuery.cjs 108 B
packages/react-query-4/dist/useSuspenseQuery.mjs 102 B
packages/react-query-5/dist/ClientOnly-********.cjs 394 B
packages/react-query-5/dist/ClientOnly-********.mjs 323 B
packages/react-query-5/dist/createGetQueryClient-********.cjs 1.08 kB
packages/react-query-5/dist/createGetQueryClient-********.mjs 1.01 kB
packages/react-query-5/dist/createGetQueryClient.cjs 98 B
packages/react-query-5/dist/createGetQueryClient.mjs 91 B
packages/react-query-5/dist/index.cjs 537 B
packages/react-query-5/dist/index.mjs 447 B
packages/react-query-5/dist/infiniteQueryOptions-********.cjs 370 B
packages/react-query-5/dist/infiniteQueryOptions-********.mjs 297 B
packages/react-query-5/dist/infiniteQueryOptions.cjs 98 B
packages/react-query-5/dist/infiniteQueryOptions.mjs 91 B
packages/react-query-5/dist/IsFetching-********.cjs 432 B
packages/react-query-5/dist/IsFetching-********.mjs 351 B
packages/react-query-5/dist/IsFetching.cjs 102 B
packages/react-query-5/dist/IsFetching.mjs 96 B
packages/react-query-5/dist/Mutation-********.cjs 393 B
packages/react-query-5/dist/Mutation-********.mjs 318 B
packages/react-query-5/dist/Mutation.cjs 100 B
packages/react-query-5/dist/Mutation.mjs 94 B
packages/react-query-5/dist/mutationOptions-********.cjs 368 B
packages/react-query-5/dist/mutationOptions-********.mjs 296 B
packages/react-query-5/dist/mutationOptions.cjs 90 B
packages/react-query-5/dist/mutationOptions.mjs 84 B
packages/react-query-5/dist/objectSpread2-********.cjs 799 B
packages/react-query-5/dist/objectSpread2-********.mjs 767 B
packages/react-query-5/dist/objectWithoutProperties-********.cjs 406 B
packages/react-query-5/dist/objectWithoutProperties-********.mjs 366 B
packages/react-query-5/dist/PrefetchInfiniteQuery-********.cjs 469 B
packages/react-query-5/dist/PrefetchInfiniteQuery-********.mjs 396 B
packages/react-query-5/dist/PrefetchInfiniteQuery.cjs 114 B
packages/react-query-5/dist/PrefetchInfiniteQuery.mjs 107 B
packages/react-query-5/dist/PrefetchQuery-********.cjs 462 B
packages/react-query-5/dist/PrefetchQuery-********.mjs 390 B
packages/react-query-5/dist/PrefetchQuery.cjs 105 B
packages/react-query-5/dist/PrefetchQuery.mjs 99 B
packages/react-query-5/dist/QueriesHydration.cjs 93 B
packages/react-query-5/dist/QueriesHydration.mjs 87 B
packages/react-query-5/dist/QueryClientConsumer-********.cjs 358 B
packages/react-query-5/dist/QueryClientConsumer-********.mjs 281 B
packages/react-query-5/dist/QueryClientConsumer.cjs 109 B
packages/react-query-5/dist/QueryClientConsumer.mjs 102 B
packages/react-query-5/dist/queryOptions-********.cjs 361 B
packages/react-query-5/dist/queryOptions-********.mjs 290 B
packages/react-query-5/dist/queryOptions.cjs 89 B
packages/react-query-5/dist/queryOptions.mjs 83 B
packages/react-query-5/dist/SuspenseInfiniteQuery-********.cjs 654 B
packages/react-query-5/dist/SuspenseInfiniteQuery-********.mjs 566 B
packages/react-query-5/dist/SuspenseInfiniteQuery.cjs 114 B
packages/react-query-5/dist/SuspenseInfiniteQuery.mjs 107 B
packages/react-query-5/dist/SuspenseQueries-********.cjs 588 B
packages/react-query-5/dist/SuspenseQueries-********.mjs 505 B
packages/react-query-5/dist/SuspenseQueries.cjs 107 B
packages/react-query-5/dist/SuspenseQueries.mjs 101 B
packages/react-query-5/dist/SuspenseQuery-********.cjs 630 B
packages/react-query-5/dist/SuspenseQuery-********.mjs 543 B
packages/react-query-5/dist/SuspenseQuery.cjs 105 B
packages/react-query-5/dist/SuspenseQuery.mjs 99 B
packages/react-query-5/dist/usePrefetchInfiniteQuery-********.cjs 373 B
packages/react-query-5/dist/usePrefetchInfiniteQuery-********.mjs 301 B
packages/react-query-5/dist/usePrefetchInfiniteQuery.cjs 117 B
packages/react-query-5/dist/usePrefetchInfiniteQuery.mjs 110 B
packages/react-query-5/dist/usePrefetchQuery-********.cjs 369 B
packages/react-query-5/dist/usePrefetchQuery-********.mjs 297 B
packages/react-query-5/dist/usePrefetchQuery.cjs 108 B
packages/react-query-5/dist/usePrefetchQuery.mjs 102 B
packages/react-query-5/dist/useSuspenseInfiniteQuery-********.cjs 374 B
packages/react-query-5/dist/useSuspenseInfiniteQuery-********.mjs 299 B
packages/react-query-5/dist/useSuspenseInfiniteQuery.cjs 117 B
packages/react-query-5/dist/useSuspenseInfiniteQuery.mjs 110 B
packages/react-query-5/dist/useSuspenseQueries-********.cjs 369 B
packages/react-query-5/dist/useSuspenseQueries-********.mjs 294 B
packages/react-query-5/dist/useSuspenseQueries.cjs 111 B
packages/react-query-5/dist/useSuspenseQueries.mjs 104 B
packages/react-query-5/dist/useSuspenseQuery-********.cjs 363 B
packages/react-query-5/dist/useSuspenseQuery-********.mjs 292 B
packages/react-query-5/dist/useSuspenseQuery.cjs 108 B
packages/react-query-5/dist/useSuspenseQuery.mjs 102 B
packages/react-query/dist/index.cjs 351 B
packages/react-query/dist/index.mjs 201 B
packages/react-query/dist/v4.cjs 351 B
packages/react-query/dist/v4.mjs 201 B
packages/react-query/dist/v5.cjs 351 B
packages/react-query/dist/v5.mjs 201 B
packages/react/dist/ClientOnly-********.cjs 609 B
packages/react/dist/ClientOnly-********.mjs 536 B
packages/react/dist/ClientOnly.cjs 97 B
packages/react/dist/ClientOnly.mjs 91 B
packages/react/dist/DefaultProps-********.cjs 996 B
packages/react/dist/DefaultProps-********.mjs 932 B
packages/react/dist/DefaultProps.cjs 118 B
packages/react/dist/DefaultProps.mjs 114 B
packages/react/dist/DefaultPropsContexts-********.cjs 328 B
packages/react/dist/DefaultPropsContexts-********.mjs 258 B
packages/react/dist/Delay-********.cjs 1.09 kB
packages/react/dist/Delay-********.mjs 1.03 kB
packages/react/dist/Delay.cjs 94 B
packages/react/dist/Delay.mjs 88 B
packages/react/dist/ErrorBoundary-********.cjs 2.15 kB
packages/react/dist/ErrorBoundary-********.mjs 2.1 kB
packages/react/dist/ErrorBoundary.cjs 134 B
packages/react/dist/ErrorBoundary.mjs 132 B
packages/react/dist/ErrorBoundaryGroup-********.cjs 1.19 kB
packages/react/dist/ErrorBoundaryGroup-********.mjs 1.12 kB
packages/react/dist/ErrorBoundaryGroup.cjs 133 B
packages/react/dist/ErrorBoundaryGroup.mjs 132 B
packages/react/dist/index.cjs 365 B
packages/react/dist/index.mjs 329 B
packages/react/dist/lazy-********.cjs 2.06 kB
packages/react/dist/lazy-********.mjs 1.99 kB
packages/react/dist/lazy.cjs 127 B
packages/react/dist/lazy.mjs 127 B
packages/react/dist/noop-********.cjs 203 B
packages/react/dist/noop-********.mjs 144 B
packages/react/dist/objectSpread2-********.cjs 805 B
packages/react/dist/objectSpread2-********.mjs 773 B
packages/react/dist/objectWithoutProperties-********.cjs 413 B
packages/react/dist/objectWithoutProperties-********.mjs 372 B
packages/react/dist/Suspense-********.cjs 909 B
packages/react/dist/Suspense-********.mjs 838 B
packages/react/dist/Suspense.cjs 98 B
packages/react/dist/Suspense.mjs 92 B
packages/react/dist/SuspensiveError-********.cjs 522 B
packages/react/dist/SuspensiveError-********.mjs 441 B
packages/react/dist/useIsClient-********.cjs 318 B
packages/react/dist/useIsClient-********.mjs 251 B
packages/react/dist/useIsClient.cjs 98 B
packages/react/dist/useIsClient.mjs 92 B

compressed-size-action

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request adds support for infinite queries to the QueriesHydration component in both @suspensive/react-query-4 and @suspensive/react-query-5 packages. The implementation allows users to pass infiniteQueryOptions alongside regular queryOptions when pre-fetching queries for server-side rendering.

Changes:

  • Updated QueriesHydration to accept both QueryOptions and UseInfiniteQueryOptions in the queries array
  • Modified the fetching logic to use fetchInfiniteQuery for infinite queries and fetchQuery for regular queries
  • Added comprehensive type tests and runtime tests for infinite query support

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/react-query-5/src/QueriesHydration.tsx Added UseInfiniteQueryOptions type support and runtime detection logic to handle infinite queries
packages/react-query-5/src/QueriesHydration.test-d.tsx Added type tests for infinite query options and mixed query arrays
packages/react-query-5/src/QueriesHydration.spec.tsx Added runtime tests for infinite query fetching, hydration, error handling, and dehydration
packages/react-query-4/src/QueriesHydration.tsx Added UseInfiniteQueryOptions type support and runtime detection logic (v4 API compatible)
packages/react-query-4/src/QueriesHydration.test-d.tsx Added type tests for infinite query options (without initialPageParam per v4 API)
packages/react-query-4/src/QueriesHydration.spec.tsx Added runtime tests accounting for v4 API differences (no initialPageParam)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 84 to 91
/**
* An array of query options to be fetched on the server. Each query must include a `queryKey`.
*/
queries: WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>[]
queries: (
| WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>
| WithRequired<UseInfiniteQueryOptions<any, any, any, any, any>, 'queryKey'>
)[]
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The JSDoc comment for the queries parameter should be updated to mention that it now accepts both regular query options and infinite query options. Consider updating it to something like: "An array of query options or infinite query options to be fetched on the server. Each query must include a queryKey."

Copilot uses AI. Check for mistakes.
Comment on lines 88 to 95
/**
* An array of query options to be fetched on the server. Each query must include a `queryKey`.
*/
queries: WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>[]
queries: (
| WithRequired<QueryOptions<any, any, any, any>, 'queryKey'>
| WithRequired<UseInfiniteQueryOptions<any, any, any, any, any>, 'queryKey'>
)[]
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The JSDoc comment for the queries parameter should be updated to mention that it now accepts both regular query options and infinite query options. Consider updating it to something like: "An array of query options or infinite query options to be fetched on the server. Each query must include a queryKey."

Copilot uses AI. Check for mistakes.
await Promise.all(queries.map((query) => queryClient.ensureQueryData(query)))
await Promise.all(
queries.map((query) =>
'getNextPageParam' in query ? queryClient.fetchInfiniteQuery(query) : queryClient.fetchQuery(query)
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The change from ensureQueryData to fetchQuery for regular queries changes the caching behavior. ensureQueryData would return cached data if available, while fetchQuery always fetches fresh data. This could be a breaking change if users pass a custom queryClient with pre-existing cached data. Consider using ensureQueryData for regular queries to maintain backward compatibility, or document this behavioral change if it's intentional.

Suggested change
'getNextPageParam' in query ? queryClient.fetchInfiniteQuery(query) : queryClient.fetchQuery(query)
'getNextPageParam' in query ? queryClient.fetchInfiniteQuery(query) : queryClient.ensureQueryData(query)

Copilot uses AI. Check for mistakes.
await Promise.all(queries.map((query) => queryClient.ensureQueryData(query)))
await Promise.all(
queries.map((query) =>
'getNextPageParam' in query ? queryClient.fetchInfiniteQuery(query) : queryClient.fetchQuery(query)
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The change from ensureQueryData to fetchQuery for regular queries changes the caching behavior. ensureQueryData would return cached data if available, while fetchQuery always fetches fresh data. This could be a breaking change if users pass a custom queryClient with pre-existing cached data. Consider using ensureQueryData for regular queries to maintain backward compatibility, or document this behavioral change if it's intentional.

Suggested change
'getNextPageParam' in query ? queryClient.fetchInfiniteQuery(query) : queryClient.fetchQuery(query)
'getNextPageParam' in query ? queryClient.fetchInfiniteQuery(query) : queryClient.ensureQueryData(query)

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

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

@manudeli It looks like the logic changed from queryClient.ensureQueryData to queryClient.fetchQuery. Was this intentional?

Copy link
Member Author

Choose a reason for hiding this comment

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

At first, why I consider changing fetchQuery and fetchInfiniteQuery instead of ensureQueryData and ensureInfiniteQueryData is that TanStack Query v4 have no ensureInfiniteQueryData.

but when I see implementation of fetchQuery and fetchInfiniteQuery, I thought it could be enough because they already check if query is stale

Copy link
Collaborator

@gwansikk gwansikk Jan 13, 2026

Choose a reason for hiding this comment

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

Is there a specific reason for distinguishing Infinite using the getNextPageParam field? Was it chosen because it's a field present in both Query v4 and v5?

(I'm just asking out of curiosity)

Copy link
Member Author

Choose a reason for hiding this comment

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

Was it chosen because it's a field present in both Query v4 and v5?

That is right

Copy link
Member

Choose a reason for hiding this comment

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

At first, why I consider changing fetchQuery and fetchInfiniteQuery instead of ensureQueryData and ensureInfiniteQueryData is that TanStack Query v4 have no ensureInfiniteQueryData.

but when I see implementation of fetchQuery and fetchInfiniteQuery, I thought it could be enough because they already check if query is stale

I understand the context you’re describing.

From an SSR and hydration perspective, this makes the fetch timing and outcome more explicit compared to relying on the background fetch semantics of ensure*.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a specific reason for distinguishing Infinite using the getNextPageParam field? Was it chosen because it's a field present in both Query v4 and v5?

(I'm just asking out of curiosity)

I also wondered whether that condition was reliable enough to clearly distinguish between queryOptions and infiniteQueryOptions. Because of that, I considered splitting them into QueryHydration and InfiniteQueryHydration, but I feel that approach might result in a poorer developer experience.

Copy link
Collaborator

@gwansikk gwansikk Jan 13, 2026

Choose a reason for hiding this comment

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

Is there a specific reason for distinguishing Infinite using the getNextPageParam field? Was it chosen because it's a field present in both Query v4 and v5?
(I'm just asking out of curiosity)

I also wondered whether that condition was reliable enough to clearly distinguish between queryOptions and infiniteQueryOptions. Because of that, I considered splitting them into QueryHydration and InfiniteQueryHydration, but I feel that approach might result in a poorer developer experience.

That's right, that's why I asked, but when looking at the codebase of Query (considering both v4 and v5),
ref: https://github.com/TanStack/query/blob/main/packages/query-core/src/types.ts#L284

  • getNextPageParam
  • getPreviousPageParam
  • initialPageParam

We have to choose one of these three. There is no internal field that distinguishes the query type.

Copy link
Member Author

@manudeli manudeli Jan 13, 2026

Choose a reason for hiding this comment

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

initialPageParam is not required field for infiniteQuery of TanStack Query v4. so I drop it as choice
getPreviousPageParam is not required field at TanStack Query v4, v5 both

getNextPageParam is the only required field to do this.

I also wondered whether that condition was reliable enough to clearly distinguish between queryOptions and infiniteQueryOptions. Because of that, I considered splitting them into QueryHydration and InfiniteQueryHydration, but I feel that approach might result in a poorer developer experience.

Because QueriesHydration wrap Hydrate & HydrationBoundary can accept dehydrated QueryClient can work with queryOptions & infiniteQueryOptions, I think that QueriesHydration handle queryOptions & infiniteQueryOptions both is better than making InfiniteQueriesHydration

Copy link
Contributor

@gs18004 gs18004 left a comment

Choose a reason for hiding this comment

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

LGTM

@gwansikk
Copy link
Collaborator

Will the document be updated in the next PR?

Copy link
Collaborator

@gwansikk gwansikk left a comment

Choose a reason for hiding this comment

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

Thanks! @gs18004

@manudeli
Copy link
Member Author

Will the document be updated in the next PR?다음 PR에서 문서가 업데이트될까요?

I need to do it now, Thanks!

…nfinite queries

- Added examples demonstrating the use of `infiniteQueryOptions` alongside regular queries.
- Updated the props description to clarify that both regular and infinite queries can be mixed in the same array.
- Translated the new content into Korean for localization.

This update improves clarity for users implementing infinite queries with QueriesHydration.
Copy link
Member

@kangju2000 kangju2000 left a comment

Choose a reason for hiding this comment

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

👍👍

Co-authored-by: gwansikk <[email protected]>
Co-authored-by: kangju2000 <[email protected]>
@manudeli
Copy link
Member Author

manudeli commented Jan 13, 2026

@gwansikk @kangju2000 Thanks for your reviewing! I added docs now too
And I add you guys as co-author

…Options for server-side data prefetching

- Added a note on using `queryOptions` with `QueriesHydration` for server-side data prefetching.
- Suggested wrapping components with their own `Suspense` and `QueriesHydration` for improved HTML Streaming.
- Updated the Korean translation to reflect these changes.

This enhances the clarity and usability of the QueriesHydration documentation.
@manudeli manudeli merged commit 8260f86 into main Jan 13, 2026
16 checks passed
@manudeli manudeli deleted the react-query/feat/QueriesHydration-use-infiniteQueryOptions branch January 13, 2026 09:47
manudeli pushed a commit that referenced this pull request Jan 13, 2026
This PR was opened by the [Changesets
release](https://github.com/changesets/action) GitHub action. When
you're ready to do a release, you can merge this and the packages will
be published to npm automatically. If you're not ready to do a release
yet, that's fine, whenever you add more changesets to main, this PR will
be updated.


# Releases
## @suspensive/[email protected]

### Minor Changes

- [#1874](#1874)
[`8260f86`](8260f86)
Thanks [@manudeli](https://github.com/manudeli)! - feat(react-query):
add support for infinite queries in QueriesHydration

## @suspensive/[email protected]

### Minor Changes

- [#1874](#1874)
[`8260f86`](8260f86)
Thanks [@manudeli](https://github.com/manudeli)! - feat(react-query):
add support for infinite queries in QueriesHydration

## @suspensive/[email protected]

### Patch Changes

- Updated dependencies
\[[`8260f86`](8260f86)]:
    -   @suspensive/[email protected]
    -   @suspensive/[email protected]

## @suspensive/[email protected]



## @suspensive/[email protected]



## @suspensive/[email protected]



## @suspensive/[email protected]
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.

5 participants