tRPC

T

tRPC

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

Join

The inferred type of this node exceeds the maximum length the compiler will serialize.

Hey, there I am running into this error when I have more than 12 routers in the mergeRouters function. The inferred type of this node exceeds the maximum length the compiler will serialize. An explicit type annotation is needed. version: latest related: https://github.com/trpc/trpc/issues/2568 // that din't work for me....

Quickstart not working

Hello there, There is a type error in the quickstart example if i'm not mistaken. I pretty much copy - pasted the example into my monorepo but i'm getting the following error in the client....

Use TRPC function inside of a TRPC function

Hi all! We have a trpc query called getProduct. I want to use this getProduct query inside of another query (getCart query). Is this possible / simple as a single trpc request rather than multiple?

Supabase with trpc

When trying to configure trpc with supabase, getting this kind of error in the console tRPC failed on <no-path>: Invariant: Method expects to have requestAsyncStorage, none available The message is kind of cryptic, does anyone have an idea what this relates to?...

Using tRPC for uploading audio files

I want to create an api router in tRPC but am not sure if the following code is doable with tRPC. If yes can you point me to a resource where I can learn how to do it? ```ts import FormData from "form-data"; import { withFileUpload } from "next-multiparty"; import { createReadStream } from "fs";...

Express middleware router type isn't correct

I am trying to build an adapter for nestjs, this adapter needs to add the express middleware but for some reason the router type isn't going through and it seems that the AnyRouter type isn't compatible. I've attached some photos of the implementation and the error. Thanks!...

Enigmatic INTERNAL SERVER ERROR

Im having a problem finding out about what is causing the INTERNAL SERVER ERROR from tRPC in my production. This is the error 👀 ```js { "level": "error",...

createProxySSGHelpers type error

Hi all! Anyone know how to use createProxySSGHelpers with appropriate createContext typing?

Can I force metadata with the createCaller?

I have custom metadata which I check within the middleware. Im trying to write tests for this. Currently no single procedure is using the meta and I wonder If I can test this somehow. Can I add meta on the fly to the procedure with createCaller?? ``` const t = initTRPC .context<typeof createTRPCContext>()...

Vitest error test

How can I test for specific TRPCError code with vitest? I managed to get the message but can't figure out how to get the code. ``` it('should throw if user roles are missing', async ({ trpcContextMock }) => {...

Rate limit in TRPC and NextJS?

Hello, I am using TRPC with nextjs without express adapter. I am wondered what is the best and free solution to rate limit some of the procedures? I found the lru-cache approach for nextjs but thought if there is a better way......

Using generics duplicates the types instead of referring to the existing types

Hi! I'm creating a backend API using TRPC, where I'm encountering a slight problem. TL;DR; when defining procedures with a generic type, instead of referring to the existing type, it copies the definition of the existing type when building the types. -...

Set custom header for fetchRequestHandler

Is this possible? currently getting cors issue. Trying to use nextjs's edge function with trpc.. ```ts import { type NextRequest } from "next/server"; import { appRouter, createContext } from "api";...

How to enforce usequery as NonNullable

I have a custom hook with infinite query. I check for undefined at the app first render and then it is reused so I know by then, the type should not be undefined. I would like to be able to infer its type without undefined conditionally. Can I do that? How to if so?? ``` export const useAppContext = (enabled = true) => api.appContext.getAppContext.useQuery(undefined, {...

How to call useQuery with params inside JSX

How can i achieve this? Thanks ``` export function MemberQueryList({ list }: Props) { ...

Sharing Enum

On the backend: I have colocated files with types and procedures (index.ts - procedures, schemas.ts - zod/ts types). If I define an Enum on the backend in the schemas.ts and would like to use it on the client(frontend) does it meat that importing that enum would boundle this file in my client? With type I can just do import type { SomeType } from '../backend/schemas' and that would be stripped If I understand correctly. But what about enum?...

Meta - unable to create default meta

Trying to follow https://trpc.io/docs/server/metadata#default-meta-chaining-and-shallow-merging I set the type of the meta add it to the builder and want to set default but seems there is no typing for the meta in the create to set the default. Am I missing something ? ``` "@trpc/client": "10.16.0", "@trpc/react-query": "10.16.0",...

trpc/react-query batching

Hi. How do you deal with batching? If I don't put any maxURLLength then I get an error 404 since it cuts of some of the requests urls... If I put url length then some requests just does not get executed since url is getting too long. I was thinking about max batching size however react-query does not have that... Any ideas on how to best deal with this?

middleware error with minimal-react example

hello! I tried to use the minimal-react version, but I get an error - it says that 'middleware' does not exist on CreateHTTPHandlerOptions<...>. Am I doing something wrong or is it broken?

how to use the same Zod validation both client and server's procedure input

When submitting forms, I need the same validation. How to reduce the repeated code?