Michael Schaufelberger
Explore posts from serversIs there a way to call procedures more directly without a router?
I read the blog post about server actions and wondered if there's a way to use a query or mutation more directly.
Does it even make sense to use a procedure more directly? I was just wondering how to more closely colocate a procedures usage near a component. About 80% of the time only a single component will need a mutation (e.g. specific form or a certain data table with component specific data).
2 replies
How do I use the rsc-rq-prefetch example with a protected procedure?
Thank you for this implementation! It looks sooo promising 😀
However, I ran into an issue when trying it out:
https://github.com/trpc/trpc/blob/next/examples/.experimental/next-app-dir/src/app/rsc-rq-prefetch/page.tsx
If we have a protected procedure instead of a public one, the server is not authenticated during SSR and an error is thrown.
How can we solve this? Can we just ignore the error and will it still work?
24 replies
Can I use the "Streaming with Server Components" strategy with tRPC?
https://tanstack.com/query/latest/docs/framework/react/guides/advanced-ssr#streaming-with-server-components
has a neat example on how to prefetch queries without having to await them. Is this something we can use with tRPC?
68 replies
How to access the request body in the onError callback?
Hi 👋
I'm having trouble getting the request's body (probably plain text) when the following error occurs in the
fetchRequestHandler
:
I've tried to get it with req.text()
but as it is already consumed, I cannot access it.
The code in question:
I would very much like to know what was sent in order to debug - in any case.
The body has to be forwarded to the callback by tRPC, correct? Or is there another way?2 replies
Example for tRPC, stable version, with RSC
Hi
This may be a stupid question...
The readme of the experimental example mentions
Note You can already use tRPC with app directory, by: using @trpc/client directly in components (both RSC and non-RSC) use @trpc/next for client componentsWhat do you mean by this? Do you have an example for that using the current stable version of tRPC? Especially the part for the RSC components. I currently wouldn't mind to use tRPC in a non-optimal RSC way. But I would like to use Next's app directory to colocate files (and not having to have code in a completely different
pages
directory).6 replies
What's the benefit of using the context instead of a direct import for the database connection?
I've wondered why I should use the tRPC context instead of just importing my database singleton from a module. Is there any benefit to it?
Because of TS performance issues, I'm creating multiple functions for bigger procedures. And passing the db connection around may be an unnecessary overhead.
12 replies
Best Practice to Fetch a Query OnDemand
What's the best practice to fetch a query on demand?
I don't have the context for the query's input in the scope of my component. (Using react-hook-form with a zodResolver that has a dynamic refinement based on the fields submitted and a components prop)
4 replies