feat(react-query): next-app-router example with prefetch helpers#5451
feat(react-query): next-app-router example with prefetch helpers#5451juliusmarminge merged 123 commits intonextfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Diagnostics ComparisonDetailsNumbers
Timings and averages
unstable timingsUnstable
|
There was a problem hiding this comment.
This is great!!!!!!!!!
Should we combine all "kitchen sink"-y things inside the existing next-app-dir-project-project perhaps? I'm personally almost loosing track of all of our parallel experimental approaches 😅
Yea probably a good idea. |
There was a problem hiding this comment.
this patch is implemented upstream here: TanStack/query#7538
| export const dynamic = 'force-dynamic'; | ||
|
|
||
| export default function Home() { | ||
| void trpc.getLatestPost.prefetch(); |
There was a problem hiding this comment.
what happens if a promise fails in a place like this?
is it safe / will node crash with "unhandled promise rejection"?
There was a problem hiding this comment.
void will ignore errors?
There was a problem hiding this comment.
Then the query will be retried when it mounts on the client depending on your retry options
|
This pull request has been locked because we are very unlikely to see comments on closed issues. If you think, this PR is still necessary, create a new one with the same branch. Thank you. |

More integrated version of t3-oss/create-t3-turbo#877
adds a wrapped proxy around createCaller that puts the promise into a server-side QueryClient. devs can then choose to wrap some client component that needs some server prefetched data with the
<HydrateClient>component. no network requests will be made from client components until the prefetched data goes stale:https://utfs.io/f/8278fdc7-572e-4b14-9f10-5f9fece747bb-yl67w4.15.58.mp4
you choose if you want to await the promise or not depending on if you also need to use the data in the RSC. if you void it, rendering wont be blocked until a
useSuspenseQueryconsumes the promiseThis gives the same behavior as the
ReactQueryStreamedProvider, but you can do authed procedures since there's no fetching in client componetns, even on the server, so no need to hack the RSC headers into the CC which causes some weird security concernsCleanShot.2024-03-07.at.23.03.56.mp4