tRPC

T

tRPC

Join the community to ask questions about tRPC and get answers from other members.

Join

can't create context when using nextjs app dir

Im trying to use the latest version of nextjs and make use of the app directory. when trying to make a create context function like they show in the docs here: https://trpc.io/docs/server/context , it gives the following error when i try to create the handler on the frontend
Types of parameters 'opts' and 'opts' are incompatible.
Property 'res' is missing in type 'FetchCreateContextFnOptions' but required in type 'CreateNextContextOptions'
Types of parameters 'opts' and 'opts' are incompatible.
Property 'res' is missing in type 'FetchCreateContextFnOptions' but required in type 'CreateNextContextOptions'
...
No description

subscriptions on edge

Trpc SSE subscriptions does not work on edge for me. Is there some specific config i need to implement? I have followed the guide for subscriptions on trpc docs (https://trpc.io/docs/server/subscriptions)...

Turn off batching for some queries?

Hiya, I have a use case where I want to set headers on specific queries (specifically cache-control private for authenticated data that's requested frequently by the client across page reloads) but because of batching, I'd need to make sure requests to these queries are never batched so the headers only refer to the one query at a time. Are there any tricks for this? Or any better approaches for my use case?...

Error: This is a client-only function.

It was working last week in 11.0.0-rc.660 but in 11.0.0-rc.682 it's not. I didn't change any code. I just rolled back and confirmed. ```ts const createCaller = createCallerFactory(this.router); const caller = createCaller(socket.ctx);...

Disable explicit content-type checks

Hey, using TRPC v11 in a production ready system. We've got an external service that sends a notification to an exposed REST endpoint on our server, using trpc-to-openapi. However, the content-type is application/x-www-form-urlencoded and v11 does check for that. Is there any way to disable this check or allow specific content-types?

Optimizing Global State Updates for Mutations Across Multiple Query Keys in tRPC with React Query

I'm using tRPC with React Query in my app, and I need some advice. I have a mutation (e.g., toggleLike) that updates a specific field (hasLiked) for posts. The mutation works fine, and I'm using optimistic updates to reflect the changes immediately in the UI. Here's the challenge: I need this hasLiked field to update consistently across multiple query keys, such as getLatest and getTrending, whenever the mutation is triggered. Right now, I have to manually update each query like this: ...

SuperJSON not tranforming dates in edge runtime

I switched trpc routes to edge runtime in nextjs, and now the superjson transformer doesn't work. Has anyone else ecountered this probelm and found a solution?

trpc doesn't work after migrating to next 15

When i upgraded to Next 15 (pages router), all trpc routes fails with status 500 on production. The result message is {"error":{"json":{"message":"req.socket.once is not a function","code":-32603,"data":{"code":"INTERNAL_SERVER_ERROR","httpStatus":500}}}}. I don't really understand if it's TRPC issue, Next issue or even Netlify issue (i host my website there, but they declare to support Next 15). Does anybody have an idea where the problem could be? I don't call req.socket.once anywhere in m...

Express/NextJS Server Side Setup

After following the T3Repo TRPC setup, I attempted to modify it for an Express API. Everything works great except... on server side requests it runs the backend as it imports createCaller from the backend. I have been lost trying to configure the NextJS Config and TSConfig to see if I can get out of this but I am out of ideas. ```ts...

subscription tracked returns a 3-tuple to frontend instead of object

I am using tracked as per recommendation in https://trpc.io/docs/server/subscriptions#tracked like this: ```ts for await (const [eventData] of iterable) { yield tracked(eventData.jobId, eventData); }...

Example on Website has no Output Types

In this example from the website https://trpc.io/docs/quickstart#try-it-out-for-yourself there is no output type nference. If i download it its the same. For example in the index.ts in the client users has no type.
const users = await trpc.user.list.query();
const users = await trpc.user.list.query();
...

TRPC Error does not say router path

Hello, I have a tRPC client that sometimes fails to call my procedures/queries. I have many of them and find difficult to track back the router path that failed. Am I missing something? In the stacktrace I only get this: TRPCClientError: Unexpected token 'A', "An error o"... is not valid JSON...

TRPC-Image

Hello, Someone know if there are some news about a way to pass an image in a TRPC mutation? I don't want to upload the image before and later send the url to the mutation, someone know how can i handle this stuff?...

Client receives 200 status when throwing TRPCError

Using pnpm, Next 14 app router and tRPC v11 mainly based on create-t3-turbo. If I have a query on the client and then throw, for example, a TRPCError with code UNAUTHORIZED, the client is getting back a 200 rather than a 401. ```ts const handler = async (req: Request) => {...

`useSuspenseQuery` with Remix causes weird "Failed to parse URL from /api" errors

I'm using tRPC with Remix (no loaders, just a client app) and as soon as I converted my codebase from useQuery to useSuspenseQuery I'm now getting "Failed to parse URL from /api". errors in my console and server. It seems as though the queries are being run on the server for some reason (where /api cannot be parsed because window.location is not available). Any ideas what's going on? Is this intended behaviour?...

Getting nitro adapter to work

I'm struggling to get my trpc procedures to work using the nitro adapter: https://github.com/michealroberts/trpc-nitro-adapter I followed the steps here to install nitro: npx giget@latest nitro nitro-app --install ...

TRPC Services!

Does trpc support or work with mobile applications such expo-react-native

SSR in Remix/React Router

Has someone managed by any chance to make tRPC SSR work in Remix/React Router?