createServerSideHelpers not offering mutation routes!
So basically:
Filters out every mutation route, i.e. I can't say
helpers.user.edit
why??Solution:Jump to solution
createServerSideHelpers is used to prefetch queries on the server. (taken from the official documentation) https://trpc.io/docs/client/nextjs/server-side-helpers#:~:text=can%20use%20to-,prefetch%20queries,-on%20the%20server
If you want to use mutations in a server component, you can check this out - https://trpc.io/docs/server/server-side-calls#mutation-example...
Server Side Calls | tRPC
You may need to call your procedure(s) directly from the same server they're hosted in, router.createCaller() can be used to achieve this.
Server-Side Helpers | tRPC
The server-side helpers provides you with a set of helper functions that you can use to prefetch queries on the server. This is useful for SSG, but also for SSR if you opt not to use ssr: true.
3 Replies
Solution
createServerSideHelpers is used to prefetch queries on the server. (taken from the official documentation) https://trpc.io/docs/client/nextjs/server-side-helpers#:~:text=can%20use%20to-,prefetch%20queries,-on%20the%20server
If you want to use mutations in a server component, you can check this out - https://trpc.io/docs/server/server-side-calls#mutation-example
Server Side Calls | tRPC
You may need to call your procedure(s) directly from the same server they're hosted in, router.createCaller() can be used to achieve this.
Server-Side Helpers | tRPC
The server-side helpers provides you with a set of helper functions that you can use to prefetch queries on the server. This is useful for SSG, but also for SSR if you opt not to use ssr: true.
Ahh gotcha
thanks a ton
I still don't understand the differences between the two. Yes, one has only queries and no mutations. But why are there 2 different ones? Why wouldn't I use only server side calls with router.createCaller({}) ?