tRPC

T

tRPC

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

Join

The inferred type of 'trpc' cannot be named without a reference

I'm getting the same error as this post: https://discord.com/channels/867764511159091230/1170736851775127564/1170736851775127564 I have a monorepo setup with an api package (copied from https://github.com/t3-oss/create-t3-turbo/tree/main/packages/api) and a server + expo packages similarly copied from that monorepo. Any ideas what I should be looking at to solve this issue?...

how to solve this

my query is declared right when i go to this url localhost:3000/api/trpc/gethello i get my output but i use use query in a component it throws this error .dont why its coming pls help asap
No description

is it possible to set a response middleware on Vanilla trpc client?

I have a vue app and I want to set a middleware on the response, whenever I get a response if I find any errors I will show a snackbar of the error, and I want that my trpc...router.query/mutation will never throw an error, because my response middleware will cache it. is it possible to do? to cache the error I can do something like this ```ts links: [...

What's the best practices around tRPC to negotiate API-versions?

In my example I'm thinking about having a native app as a tRPC client and a locally deployed docker image as the tRPC server. Both of these are distributed "binaries" that might not be the latest version at any given time. Sooo. is there any best practice on how to identify tRPC "schema" changes so that I could implement api-version-negotitation? With REST I'd do it with a list of endpoints and what versions the server support for each endpoint and let the client match that to what it supports t...

Is there a way to pass context or cookies to the client provider?

```typescript export default function APIProvider({ children, }: { children: React.ReactNode;...

Is there a way to pass context or cookies to the client provider?

```typescript export default function APIProvider({ children, }: { children: React.ReactNode;...

Why deprecate experimental_standaloneMiddleware?

I am reading https://trpc.io/docs/server/middlewares#experimental-standalone-middlewares, but it's still not clear to me why experimental_standaloneMiddleware was deprecated. It says we can use .concat() to use "standalone" middlewares. However, I don't see how they are related exactly? The example shows we can use a plugin. This would take in a new procedure to do concating of procedures. But this is not exactly what I want. In my code I have this: ```ts...

shared useTRPCClient hook conversion to v11

In our mono repo, we have 30 or so MFEs which all use the same TRPC client setup. So, we abstracted the inner workings of getting the TRPC client set up away in a different package as a hook. Now, I'm converting the code to v11, and I'm running into deprecation warnings and typescript errors. Our hook looks like this: ```typescript import { useState } from 'react'; ...

Question: Is there a way to have a base interface for Trpc router?

Hi, So I am trying to see if there is way to keep methods inside trpc routes consistent, Like in case of classes you could define an interface with required functions. Is there a way to do this in Trpc router aswell? Like ex: ...

persistedQueries & indexedDb

Would like to know if someone else has tried out the feature and/if got it work, I'm trying to recreate the Linear's approach to it's snappy feel and all-data-ready on initial page loads. This is the current implementation I have following the RTK docs ```tsx // IDB custom persister...

Public and Private procedures Not working with Clerk and Prisma

I have initialized a create-t3-app. I want to use clerk as my auth provider. I have ran into a problem midway when setting up the middleware and making changes to the prisma client. Now this is what the api calls are returning

Properly handle unifying interfaces from tRPC call?

I have two types of objects in my database, quests and tasks, which share several common properties, however they are named slightly differently (e.g. quests.startingAssessmentContent and tasks.startingContent), as well as a component which reads the contents of either one of these objects interchangeably. I want to unify my interfaces for the tRPC procedure outputs for these two objects, so I made a custom hook: ```Typescript...

Type 'QueryClient' is missing the following properties from type 'QueryClient': queryCache, mutation

I'm getting this error:
Type 'QueryClient' is missing the following properties from type 'QueryClient': queryCache, mutationCache, logger, defaultOptions, and 4 more.ts(2740) context.d.ts(48, 5): The expected type comes from property 'queryClient' which is declared here on type 'IntrinsicAttributes & TRPCProviderProps<CreateRouterInner<RootConfig<{ ctx: object; meta: object; errorShape: DefaultErrorShape; transformer: DefaultDataTransformer; }>, { ...; }>, unknown>'
...
Solution:
Just run the npm install again and you should be good or downgrade @tanstack/react-query to @tanstack/query@4

How to properly handle Prima selects/includes with tRPC?

Hello, my understanding of optimizing procedures to be the most efficient would be to enable one procedure to handle different use-cases. So I'd like a procedure like getById to take a list that allows all possible attributes from the prisma models and optionally a list of models to include. Currently, I define a list of all attributes on a global level for each router, that includes all includable Fields (I'd then do the same for the selectable fields). But that - even with just the includable fields - ends in this madness: ...
Solution:
```ts const includableFields = z.enum([ "comments", "readingProgress", "novelInsights",...

onSuccess with createTRPCProxyClient

What is the best way to setup onSuccess with createTRPCProxyClient?

trpcNext from client for testing

Hi guys, I have created a client that uses a mock database for testing. Can I create a context and trpcNext to use in my Components and test the whole component together with the backend but without creating the server? Thank you for your help ...

Missing content type header for mutations leads to 405

Im migrating my app from Next Pages Router to App Router. I implemented the new trpc wrapper as explained here and everything seems to be working as I expected, except mutations. Mutations fail on preflight with a 405 (local development, same server). The only difference between the "before" and "after" of the migration (As well as the only difference to queries) is that mutations are missing a content-type: "json" (See attached). Any idea how I can fix this?...
Solution:
Ok .... so for prosterity the issue was in the server API route. it was missing a POST handler. Fixed version: ```tsx import { fetchRequestHandler } from "@trpc/server/adapters/fetch";...
No description

Is there any way to temporarily disable mutations?

My goal is to move into a read-only mode temporarily. I'm thinking anything could be fine as a short term solution. 1. Throw an explicit error when mutations try to be called 2. Procedure not found error...

After upgrading to 11.0.0-next-beta.300, every request throws zod error

I didn't do anything but upgrading the trpc, and the error throws:
{"issues":[{"code":"invalid_type","expected":"object","received":"undefined","path":[],"message":"Required"}],"name":"ZodError"}
{"issues":[{"code":"invalid_type","expected":"object","received":"undefined","path":[],"message":"Required"}],"name":"ZodError"}
...
No description

Setting up tRPC for next.js with edge AND serverless functions

tldr: I am trying to build an app that uses both edge AND serverless functions by creating separate endpoints. Has anyone ever done this successfully? I am building an app that runs openai-API-requests and is connected to a Planetscale mySQL-DB with a prisma-layer (t3-setup). All functions are serverless. I am facing timeout issues on the openai-requests, since they are taking quite long. I am trying to switch all openai-functionalities to run on the edge. This means longer timeout-limits on vercel and the ability to stream the response. All the other functions need to remain serverless, since they use prisma, which isn't available on the edge. What I have tried so far:...