tRPC

T

tRPC

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

Join

How to serve files with trpc?

Is is possible to serve files with trpc? E.g., by creating a middleware and returning directly from the middleware? I can't seem to serve files with trpc. Should a separate server be set up just for file serving?

tRPC in Next without api rotes

Hello! I have NextJS app that gets data in gSP using some third-party client. This data comes untyped, and i'm thinking if tRPC can help me to manage this behavior in a better way, than just zod validation. One more thing - i do not want to make some public endpoint for quering this data. But I can't find any examples of tRPC usage in NextJS without API routes. Does it mean that tRPC do not fit my task as it actually "a gates of BE part"?...

getting the progress of a trpc query

Hello, I want to be able to stream the progress of a trpc client query call, so I can link it to a progress bar in the ui. Is this possible?

wrapper on useMutation (and another for useQuery) for creating multiple hooks

hi i want to create a wrapper for my router, basically I would like to achive somethink like that This is my appRouter: ```...

useQuery returning old data with new params

I have a react component that takes in a date range and calculates a users net worth (sums up all assets) between that window. For some reason it is returning the previous drop downs data instead of the current one. I'm not sure if I have to use a queryKey to force a new fetch. ```import React, { useState } from "react"; import type { DateRangePickerValue } from "@tremor/react"; import {...

Calling a tRPC service from another tRPC service

I have 2 services (App1 and Service2) App1 is client facing and uses trpc well But occasionally App1 backend needs to call a procedure on Service2 Should I just use the vanilla client on App1 backend and import types/context from Service2?...

charset=utf8 results in empty input

I'm using trpc-openapi and some of our customers are using Zapier to communicate with it. Zapier uses the header Content-Type: application/json; charset=utf-8 - note the additional charset=utf-8 When charset=utf-8 exists, the input to the relevant procedure is {}...

Is there a way to alter the query key generated by trpc?

I want to pass a boolean flag (initial) to the backend saying if it's a first call of a given procedure. I don't want trpc to create two separate queries because of this. Is there a way to remove this initial parameter from the generated query key? Or is there perhaps a better way to tell the backend it's the first fetch?

useMutation throwing 500 errors

I've setup my next 13 app router project and started using some queries that worked fine, however the only route I have for mutations fails without any detailed error. I'm using the createTRPCReact with a custom client for RSC. ```ts "use client"; import { QueryClient, QueryClientProvider } from "@tanstack/react-query";...
No description

TRPC Nextjs App Router API Base URL

Is there any issues with me placing trpc route handler in the root of my api folder? I don't really like having the /trpc in front of my api calls. I want it abstracted. Also, is it possible to use slashes for the url instead of camel case? I want for example do: /api/contact/create

Turborepo, nextjs, vite react app, express server

I have following structure Apps: First Frontend - Nextjs app Second Frontend - Vite ReactApp Backend - Express Server...

Router/Middleware Chaining in V10

Heyo, finally migrating from v9 to v10 after putting it off for a while. Is it just me, or is this migration pretty rough? Really enormous amount of changes and not really a way to do it incrementally. I found interop() didn't work at all, and still not sure if it's going to run after everything. Anyways, in v9, I used router/middleware chaining to establish secure namespaces. That is, every query within, for example, 'A.B.C.', is using middleware established in B. It seems like in v10, middleware has been moved from the router layer to the procedure layer. Do I need to manually rewrite every function in my routers to use this new paradigm, or is there an equivalent?...

throwing custom errors from mutations

any idea why trpc is ignoring the catch expression? it just throws its own error about unique constraint violation...
No description

trpc in a pnpm monorepo

Hi all 👋 I was wondering if there is a recommended setup for monorepos, in our case with pnpm workspaces. app1 is a node.js service (node v18.16.0) with the trpc server. We are using zod for validation and type inference....

TS Error with React when creating client "useContext" collides ....

when creating the client i get following error: The property 'useContext' in your router collides with a built-in method, rename this router or procedure on your backend." | "The property 'Provider' in your router collides with a built-in method, rename this router or procedure on your backend." | "The property 'createClient' in your router collides with a built-in method, rename this router or procedure on your backend." | "The property 'useQueries' in your router collides with a built-in method, rename this router or procedure on your backend." | "The property 'useDehydratedState' in your router collides with a built-in method, rename this router or procedure on your backend." Anybody an idea? ...

Type 'NextRequest' is missing properties from type 'NextApiRequest'

Enviorment: Node 18, pnpm Hi, I'm facing an error, where in my app i get this error at createTRPCContext({ req }): ``` Type 'NextRequest' is missing the following properties from type 'NextApiRequest': query, env, aborted, httpVersion, and 66 more.ts(2740)...

Type '{}' is not assignable in server query

Type '{ input: { slug: string; }; "": any; }' is not assignable to type 'string | StringFilter<"Category"> | undefined'. ``` ts getCategoryBySlug: publicProcedure .input(z.object({ slug: z.string() }))...

Using HTTP:POST for `query`?

Hey guys, thanks for the awesome library! My application involves making a query with a large amount of JSON data. However, since we use HTTP:GET under-the-hood for queries ( including batching ), I run into header length limits. Since we deploy to AWS, we are also restricted to the length limit imposed by Amazon ALB. Due to this, I have the following questions : - Is it currently possible to use HTTP:POST for query and mutation? ...