Use this tag for tRPC, the TypeScript library for defining and using type-safe APIs for use with TypeScript servers and clients. For Remote Procedure Call, use [rpc] instead.
Questions tagged [trpc.io]
124 questions
3
votes
3 answers
How to update data that React Query has already fetched so that I do not have to refetch all the data?
Currently, my code looks like this. When mutation is successful, I have to refetch all the data because tasks will not be updated. How can I update the client-side tasks when I submit or delete a task?
const { data: sessionData } = useSession()
…

lightbluepoppy
- 141
- 1
- 10
3
votes
1 answer
Create T3 App Redirect inside a TRPC middleware if user is not signed
How can I trigger a redirect on the server side if a signed in user has not completed their profile page
const enforceUserIsAuthed = t.middleware(({ ctx, next }) => {
if (!ctx.session || !ctx.session.user) {
throw new TRPCError({ code:…

Mani Muridi
- 400
- 4
- 18
3
votes
0 answers
TRPC: TypeError: Cannot read properties of undefined (reading '_def')
I'm using the T3 stack and whenever I try to query one of my controllers I get this type error on the server. On the client I'm getting TRPCClientError: Unexpected token '<', "

Storm
- 117
- 1
- 8
3
votes
0 answers
react-native trpc always loading
I have tried using trpc with the fastify integration, and it works fine.
However, when I tried using it in my react-native app, it does not work (it already worked with next.js) It only displays loading as a status.
const getBaseUrl = () => {
…

hinterberger-thomas
- 115
- 1
- 5
3
votes
2 answers
How do I invalidate queries and fetch latest data in TRPC?
I am simply trying to get latest data from the server after performing a mutation. My code looks something like this:
const utils = trpc.useContext()
const markAsUnreadMutation = trpc.useMutation(['update-mark-as-unread'], {
onSuccess() {
…

Arpit
- 467
- 1
- 8
- 18
3
votes
2 answers
tRPC throws an error in setData (useContext wrapper of TanStack Query) after I updated it from v10-rc to v10
Before:
├── @tanstack/react-query@4.14.6
├── @trpc/client@10.0.0-rc.4
├── @trpc/next@10.0.0-rc.4
├── @trpc/react-query@10.0.0-rc.4
├── @trpc/server@10.0.0-rc.4
After:
├── @tanstack/react-query@4.14.6
├── @trpc/client@10.4.3
├──…

lightbluepoppy
- 141
- 1
- 10
3
votes
2 answers
Optimistic Updates with React-Query (TRPC)
I am not sure how I would do optimistic updates with trpc? Is this "built-in" or do I have to use react-query's useQuery hook?
So far, I am trying it like so, but it's not working:
const queryClient = useQueryClient();
const updateWord =…

antonwilhelm
- 5,768
- 4
- 19
- 45
3
votes
1 answer
react-query, react-hook-form and form validation
I'm building a form (based on react-hook-form) to filter a list of events by start and end date. The list is retrieved with react-query's useQuery() call. There's a zod-based validation in place (via @hookform/resolvers) to make sure the end date…

Tobi Kremer
- 618
- 6
- 22
3
votes
0 answers
How to pass a tRPC procedure to component and type correctly
I'm trying to pass a tRPC v10 query procedure to a custom table component and type it correctly. Below is a simplified code snippet of what I'm trying to achieve.
I tried typing it as a QueryProcedure but then I get Property 'useInfiniteQuery'…

samvdst
- 618
- 7
- 22
3
votes
1 answer
Cookies and tRPC
I'm having trouble understanding how to handle cookies with tRPC.
I'm confused particularly about how to send cookies back from the server, and then how to read the cookies from the res. Every SO and GitHub post I've found regarding tRPC cookies has…

Brandon-Perry
- 366
- 4
- 18
2
votes
0 answers
Problem with fetching email (node-imap library) on next.js using trpc
I try to develop simple app for extracting OTP code from my inboxes on next.js
To get the email data from mailboxes I use nodejs with the help of node-imap library.
I use trpc on next.js to call the node code (actually I'm not sure if this is a…

masu.mo
- 783
- 1
- 12
- 22
2
votes
1 answer
Getting TRPCClientError: Unexpected token '<', "
I am planning on building an app using SST and tRPC. I have never used either so I am going through the docs and quick start to better understand the material. I came across an issue where the call is not rendering on the front end. Im not sure if I…

BillyG
- 21
- 2
2
votes
0 answers
How to call function next() of tRPC middleware when using Passport.js?
I'm having a problem using passport.js to authenticate jwt with tRPC middleware. I tried calling thre next() function in the callback of passport.authenticate function but it doesn't seem to be working and results in the error,
{"message": "No…

mickyngub
- 21
- 1
2
votes
1 answer
tRPC invalid hook call in react function component
I am trying to create a new user when the user connects to the site with their wallet.
When the user clicks the button to connect, the useAccount hook will return an address of type string.
I then want to create a new user with this address in my…

Sean
- 1,368
- 2
- 9
- 21
2
votes
0 answers
Next 13 throwing error on tRPC client promise
I know Next 13 is only in beta, but recently I started experimenting with tRPC and Next's data fetching. I have a server component that queries projects.getAll from my tRPC server and puts them in a Component.
Server Error
Error: Objects are not…

Daisho Arch
- 520
- 2
- 16