T
tRPC

Recommended file structure for next.js?

Recommended file structure for next.js?

JFJack Fischer10/5/2022
Hey all - using tRPC heavily with next.js and it's great. Our main [trpc].ts file is getting huge and unwieldily - wondering what the recommendations are out there for organizing?
Ttrash_dev10/5/2022
hi, have you checked out this next example https://github.com/trpc/trpc/tree/next/examples/next-prisma-starter also check out the docs here: https://trpc.io/docs/v10/nextjs theres a recommended file structure section
JFJack Fischer10/5/2022
Hey thanks a bunch. I think these give you the basic layout but not how to break out [trpc].ts - is it recommended to put individual query/mutations in that same trpc directory for example?
Ttrash_dev10/5/2022
i believe the starter projects shows you how to break up your routers and keep them outside the [trpc].ts file https://github.com/trpc/trpc/blob/next/examples/next-prisma-starter/src/pages/api/trpc/%5Btrpc%5D.ts the server folder structure: https://github.com/trpc/trpc/tree/next/examples/next-prisma-starter/src/server
JFJack Fischer10/6/2022
Got it thanks!!
UUUnknown User10/7/2022
Message Not Public
Sign In & Join Server To View
Jjulius10/7/2022
@latest uses v10 now too 🙂

Looking for more? Join the community!

T
tRPC

Recommended file structure for next.js?

Join Server
Recommended Posts
Unhandled Runtime ErrorTRPCClientErrorCall Stack Function.from node_modules\@trpc\client\dist\TRPCClientError-09b8a26b.esm.js (57:0) transSharing middleware between TRPC serversWe currently have *microservices* REST API's on Cloudflare Workers and I'm thinking about moving thiIs `trpc.withTRPC` for Next supposed to work with pages or only `_app`?I'd love to only have TRPC mount on certain pages of my Next.js app. Is this currently supported?Are there any example of subscriptions working with react native ?queries and mutations are working pretty well with react native, I'm unable however to get subscriptRecommended way to prefetch client-sideIn react-query, you can do ``` queryClient.prefetchQuery(['todos', input], queryFn) ``` In trpc, IRevalidate API route from procedureHi, is there a way to revalidate a statically generated page from a trpc procedure? https://nextjs.Modifying payload client-side before cachingSay I have a payload that includes something like `category_id` in each of the items returned e.g.: Response headersIs it possible to modify the response headers from server to client?API Response caching not working on vercel ⁉I've followed the instructions in https://trpc.io/docs/v9/caching for API Response caching and it's when throwing a TRPCError, is there a way to include an internal error code ?for the given screenshot, if such error happens I wanna prompt the user to login or something.extra json property added after data when consuming a query hook.I have this issue where when consuming a RQ hook there is an extra `json` object that I have to useProblem using next+ssgHi, Im trying to use the @trpc/next SSG Helper and I get content on the page. Although I noticed thaError handlingWe have some trpc routers that make requests to another api - we use axios for that. I'd like to forPlease read before creating a postWe're trying out forums for help now. Please make sure to select the relevant tags on your post. Als