tRPC

T

tRPC

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

Join

No "query"-procedure on path "auth.getProfile"

I am getting bunch of these errors and I can't figure this one out yet. I saw bunch of issues created related to this error but everyone seem to have magically resolved it on their side 😄 I am using tRPC in a conjunction with NextJS 14 based on Create t3 app. I think the issue has started after I introduced the translation of my website (i.e foo.com became foo.com/en or foo.com/fr), I wonder if it might be linked and if so, if I can resolve this by pointing to correct url or something? This seems like an error coming out from tRPC as I don't even get logs in my written query on server side. ...
No description

Type '[]' has no properties in common with type 'MutateOptions<{ id: string....

Is it possible to get this to work? i am trying to make a single action that works across 2 routers. ```ts const DeleteMedia = ({ id,...

Strange error when testing with Auth.js v5

Hi there, I just created a fresh Next.js project and added next-auth version 5 beta for authentication and tRPC for server logic. I have followed the setup documentation for both next-auth and tRPC. Setup Overview...

tRPC failed on beehiiv.fetchBeehiivPosts: Invalid state: Controller is already closed

Is there any solution to this error. I am getting while I try to hard refresh a page where I am calling beehiiv.fetchBeehiivPosts

Is there a way to configure a trpc router to require an output() schema to be specified?

I would like to require the output() schema to be specified on all the queries and mutations in my project through some sort of typecheck or linting rule, as a way of documenting API though code and making our api specifications more explicit. Is there any way through router config or through linting config to force this to be specified? I am unfortunately not familiar with writing custom eslint rules so I don't know how to approach it if I wanted to write a custom eslint rule myself

Errors not caught in procedures

I have an application that uses Solid Start @solidjs/start. Most Solid Start apps use the fetchRequestHandler. It seems that the behavior changed recently in that errors thrown inside procedures no longer get caught and will crash server. Environment: - node 20.3.1 - pnpm (I have tried on npm as well)...

silent failure on client query?

Hey friends, long time listener, first time caller 😉 I have encountered a quite confusing quirk that I'm not sure how to start reasoning about... I have been running a trpc client call (all my trpc packages are currently v10.45.2) in a nextjs 14 (w/ app router) application. So the follow code has been working when the selectedSession updates in the context...

Auth0 + fastify + tRPC

Hi, I've inherited a tRPC React/fastify app and need to migrate the auth from supertokens to auth0. I'm running into an issue with the createContext function for the fastifyTRPCPlugin and would love to hear whether this is the right approach or if y'all have any suggestions. Fastify server...

Getting the type of context

Is it possible to get the type on a context object that is passed into a specific TRPC procedure after it is modified by the middleware? If so, whats the best way to go about this? Thanks...

Is it possible to perform attribute-based authorization after the .query?

I have a TRPC method, getStudentGradeById, that accepts the gradeId. I want to return the grade only if the student owns it. the current code is: ``` protectecProcedure...

How is inner context persistent if we call 'createContext' for every batch?

As per title. According to the docs, inner context doesn't depend on the request, and is useful for persistent objects like your database connection. However, given that createContext is called for every request, I fail to see how calling createInnerContext inside of createContext provides persistence? Docs that I read: https://trpc.io/docs/server/context#inner-and-outer-context...

does anyone know how put vs post calls map to the trpc procedures provided? (query vs mutation)

I did check out the documentation but i only mentions GET and POST, not PUT . https://trpc.io/docs/rpc GET -> QUERY...
Solution:
You can use trpc-openapi to have both PUT and POST etc, but the tRPC client will still call the POST endpoint for mutations I believe.

Next.js. Migrating to turbopack casues context error

Error: `` react-dom.development.js:20662 Uncaught Error: Unable to retrieve application context. Did you forget to wrap your App inside withTRPC` HoC? at updateDehydratedSuspenseComponent (react-dom.development.js:20662:17)...

how to proxy a router

hey im building a chrome extension that has two adapters .. one is for communicating with the api server (lets call it an apiRouter) and another to communicate between the different parts(worlds) of the chrome extension (specifically the background script and a content script). since apiRouter is only available for the background script , but the extensionRouter is available for all the other parts I'd like the extensionRouter to proxy the apiRouter , in such a way that a query() from the api AppRouter would be available natively on the extensionRouter ...

Is there a way to pass parameters to procedure on call?

I would like to pass the required permission to the procedure like in this example: ``` create: authedProcedure("user.create").input(createUserSchema).mutation(async ({ input }) => { return createUserHandler({ input }) }),...

Complex type inference on router outputs?

What are the best practices on complex outputs from routers and typing on the FE? We are doing quite a bit of munging of data from multiple sources, so there's no real concept of an upstream "primitive" as there would be in a simple trpc + nextjs + prisma setup. How is everyone doing typing in a scenario like this? It feels brittle to bind a UI element to the response from a router as that will intrinsically bind those two elements together, making the component non-reusable. Is there a typing layer for trpc that sorta behaves like GQL, where you get a meta layer of types from the router responses?...

Where to put clean up code?

I have a DB connection setup in my createContext that I must explicitly close per-request. But I cannot find any good spots in the TRPC lifecycle to make that call. I tried just running it in a middleware, but seemingly that is invoked on each query in a batch independently, whereas I need it to be called once all queries have finished. FWIW: I am using create-t3-app with @vercel/postgres and createClient. ...

Trigger lambda configured with trpc using other events

Can I trigger a lambda configured with trpc api gateway adapter using events other than httpApi like from an sqs or a dynamodb stream event, how would I handle these requests with the router?

useInfiniteQuery does not exist on appRouter t3-Stack Prisma

I'm using appRouter and trying to do pagination with useInfiniteQuery() but i've got the next typescript error: Property 'useInfiniteQuery' does not exist on type '{ query: Resolver<BuildProcedure<"query", { _config: RootConfig<{ ctx: { headers: Headers; db: PrismaClient<{ log: ("query" | "warn" | "error")[]; }, never, DefaultArgs>; session: Session | null; }; meta: object; errorShape: { ...; }; transformer: typeof SuperJSON; }>; ... 5 more ...; _output_out: unique symbol; } and I can't find anything about it. ...