-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs: Provide examples using tRPC with Next.js app router #5277
Comments
Seconding this! It's been hard to find any authoritative sources on TRPC usage with the App Router. |
Yes, please. I'm going crazy here trying to prefetch an infinite query and I'm not smart enough to figure it out myself. Anyone got some example code for how to get it to work? I've seen some examples where they use an server side helper, call prefetchInfinite, dehydrate the queryclient, then pass it to a HydrationBoundary. But yeah, can't get it to work. |
Hey @maryamkhan14, you can refer to this video https://www.youtube.com/watch?v=qCLV0Iaq9zU to set up trpc with Next.js App router, also you can go to my repositories and check the Pestile repo which is set up using Next.js app router with Trpc. |
This can help you and I will be writing a blog article by today This is minimalist example and very easy to understand https://github.com/Pavan-Rajesh/tRPC-Nextjs-App-Router-Minimal.git Some of the things in the above video are deprecated and some of the docs are also deprecated but vscode helped me ^-^ |
Bump. Also relates to #5625 I can find no explanation anywhere for how to cache trpc endpoints when using the NextJS App Router |
@jeffrey-computers I think Nick Lucas (don't want to ping him here) mentioned on twitter, that the documentation is not being updated until v11 is released: https://x.com/NckLcs/status/1788275302340100304 |
I think the closest thing to what we want to recommend if you have a monolithic app is to use If you're running a separate service for your api layer, it'll likely look quite different. If you are making an SPA, it looks more like how it always has. It's hard to know what people actually expect and how people want to use trpc for in this new world where React, since RSC and server actions, solves a lot of the things that trpc was created for. |
Here's my take on why I'm still interested in TRPC and why I'm not as hyped about RSC and Server Actions as many.
For me, State Control is the most important point, though others matter as well. When doing frontend-dev, I've been building mostly admin panels these days. Since around 2021 NextJS has started to move away from SPA mindset (heavy-interactive), and cater more to heavy-content customers like E-Commerce and image/video platforms. They optimize first load "at all costs" but the first load does not matter nearly as much for interactive apps like games, CMS', etc. Consequent loads, UX performance, dev. experience matters more... and that part was completely ignored (before React 19 that drops stale internals and fixes memoization routine, something good at last). Vercel is free to pursue their business goals, of course, but engineers know that "strongly optimized for X" is inevitably "suboptimal for Y". Cache invalidation (that NextJS wants me to perform on the server) couples actions to frontend URLs making them barely reusable and/or requires even more wrapping code. Invalidation via TLDR. If you have most of your logic on the backend... why not use Go/Python instead of NextJS (TypeScript)? |
This issue has been locked because we are very unlikely to see comments on closed issues. If you are running into a similar issue, please create a new issue. Thank you. |
Area of Improvement
Only tRPC using page Router in Next.js are present in your documentation. Please Provide Examples for tRPC using Next.js app Router
Link to related docs
https://trpc.io/docs/client/nextjs/setup
Additional information
No response
👨👧👦 Contributing
Funding
The text was updated successfully, but these errors were encountered: