tRPC

T

tRPC

Move Fast & Break Nothing. End-to-end typesafe APIs made easy.

Join

TRPCContextState not found in v10

In our v9 app, we used TRPCContextState from internals to type out TRPC utils, importing it like import { TRPCContextState } from '@trpc/react-query/dist/declarations/src/internals/context'; and using it in types like trpcUtils: TRPCContextState<AppRouter, any>; Is there a quick alternative to this? Can't find it in the the latest trpc10 code packages....

RateLimiter for fastify tRPC routes

Hi, I would like to add Ratelimiter to a specific fastify trpc route, are there any solutions available yet? Or do we need to write our own solution for this?

Subscriptions

are we able to send data over with subscriptions, to allow for full duplex communication ?

Query tRPC the right way

If you use graphql, you can precisely query what you exactly need and avoid over fetching, so you can do something like this: ```gql user { id username...

child router question

let's say we have a monorepo, one server, two client apps (cat and dog). we make one appRouter, like: export const appRouter = t.router({ cat: catRouter, dog: dogRouter })...

How to force SSL on projects using tRPC?

Hello everyone, I'm working on a project that uses create-t3-app as boilerplate. My project is hosted on heroku. I have an issue with forcing HTTPS connection. Before tRPC, I was able to solve this issue by using express-sslify like it was explained in this post on Stack overflow https://stackoverflow.com/questions/67490760/how-to-enforce-ssl-on-a-node-js-app-on-heroku Is it possible to enforce SSL on projects using tRPC?...

AWS Lambda / How to set Cookies inside Procedures

How can I set and remove cookies similar to ctx.res.cookie(..) with Express when using the aws lambda adapter. My configuration is: * node 18 * tRPC 10...

Massive Type Errors on tRPC 10 Legacy Router against MergeRouter

We're trying to upgrade to tRPC 10 but I am running into a massive type clash when trying to merge routers. Our tRPC 9 router is huge. I've interop'd all of these routers and the legacy router itself, but when I get to the point at which I am merging my new router with my old legacy router, my .merge statements on my legacy router blow up a massive illegible typescript error. Attached is a glimpse, can provide more info if necessary...

Is it possible to create 2 routers inside a single file?

I am having an issue in which it is impossible to me to use a class instance within 2 routers. I tried declaring the routers in a single file and then exporting them, it doesn't work. The issue I am facing is this: https://github.com/vercel/next.js/issues/49309 Any insight/help would be greatly appreciated....

Use onError to change an application error into a TRPCError?

I want to use the onError handler to change any instance of a custom application error into a TRPCError (I want the HTTP Status code to be a 401 rather than a 500). I tried this but it doesn't work... ``` onError({error}) { if (error instanceof AccountLimitError){ error = new TRPCError({ code: 'UNAUTHORIZED', message:error.message })...

Increasing Body 1mb limit

Hey, Im trying to build an application that allows sending of base64 encoded files to my next.js server through TRPC. I read online that the only currently supported way to do that is by base64 encoding and then shipping it over through JSON. Is there a way to increase the default 1mb limit on post requests? For my purposes 2-4MB would be more than enough But i am expecting a few at > 1mb filesize.

Nitro and tRPC in vercel-edge

Hey there! I hope this is the right place to ask for help. I am trying to deploy an application with Nitro and tRPC with the vercel-edge preset. I am getting a weird proxy error when I deploy it without making any changes to how tRPC is handled. ```...

How to retrieve and receive Bigint data to/from TRPC procedure

Node: v16.15.1 I'm trying to return an object which contains an amount property from one of my TRPC procedures... This property should retrieve a bigint. Unfortunately, I'm receiving error: TypeError: Do not know how to serialize a BigInt...

TypeError: Cannot read properties of null (reading 'useContext') when using useMutation with TRPC in

I'm encountering an error in my Next.js application when trying to use the useMutation hook with TRPC (Typed RPC) library. The error message I'm getting is "TypeError: Cannot read properties of null (reading 'useContext')". It seems to be related to the useContext hook, but I'm not sure how to resolve it. Here's the relevant code snippet within a Next.js component, including the TRPC setup: ´´´...

Initial websockets getToken() returns null: next-auth + websockets :)

Hello! So the way I am trying to authenticate websockets is like this: ```...

Can I get the original type name, instead of the shape, with query?

I'm not sure how to explain it, so, here's a screen shot:

TRPCClientError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON Error

Hello folks, I'm getting an issue with my integration, I'm a newbie in tRPC and I can't work well my integration with next, next-auth, and Prisma to make an authentication. When I'm doing the request to the server, (I think) I'm receiving the following error failed to load resource: the server responded with a status of 404 (Not Found) ...
No description

trpc cors

my sveltekit app is running on https://example.com with tRPC and it's making requests to http://127.0.01:3001/api/trpc (otherwise it won't work) but I'm getting a CORS error (' The Same Origin Policy disallows reading the remote resource at http://127.0.0.1:3001/api/trpc/model.getAll?batch=1&input=%7B%7D. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing)'). how can I fix this?

T3 app tRPC external calls

Currently i'm just making Post request and formatting my payload to ```{ "0": { "json": { ....data <--- actual data....