tRPC

T

tRPC

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

Join

useSubscription simplified with react query

Hi Guys, looking for a way to simplify the use of useSubscription. Currently I do the following: 1. create local state with the type of my subscription 2. call useSubscription, and pass onData to a setData ...

Next.js app router catch-all HTTP methods

The app router already supports the catch-all file for route resolution, but AFAIK still expects separately method exports like export function GET(). I think this means we can't provide the tRPC NextApiHandler from the app router and we still need to use the pages directory (not a big deal but adding a whole extra directory just for the tRPC route currently). Any way to provide the tRPC Next handler from the app router?...

TRPC Vanilla Client (T3 stack)

I'm using the T3 stack (Next + TRPC + etc) and I'm trying to figure out how to do vanilla queries that don't come with the baggage of a hook.
const hello = await api.example.hello.useQuery()
const hello = await api.example.hello.useQuery()
...

Multiple Inputs on TRPC Procedure?

Essentially I'm trying to pass a cart (array of objects) into a public procedure (doing so fine). I want to add user object to the call too but cannot find any info online about multiple inputs into a procedure. Is anyone able to help please? More info here https://stackoverflow.com/questions/76691553/trpc-multiple-inputs...

adapter for hono or hattip?

we’ve got adapters for express, stand alone node and next. I wonder how easy would it be to make adapters for more modern backend frameworks or if there are any that I couldn't find googling?...

Keep getting 500 error response I can't figure out

With both queries and mutations I get back this response saying that there's html in the response and it's invalid json. there's html because I use nextjs and some error is causing an ssr page to be given instead of a trpc error json. I've tried a few things and have found out that it's not even hitting my middlewares when giving this error. I'm not sure what's causing it. All help appreciated, ask for more info and i will provide 👍 i am using createTRPCProxyClient...
Solution:
turns out i forgot to setup env files. it was all working on my pc but i started coding more on my macbook lol

tRPC & redux toolkit query

Node 18, pnpm, ts, vite, toolkit. Cant find any proper info how to use tRPC with toolkit query; If I do just a simple req in component via client.users.getUser() it works perfect, but with toolkit got this issues....

how can I globally set a "middleware" callback for all onErrors on my React Query calls?

this is a little specific but Im struggling on it Im using the TRPC server as a BFF for my backend and for every call on the client I'm sending a token so backend can authenticate it, when the token is not valid anymore api return status code 403 (forbidden). what I want to do in my FE is that every onError call I check the status to see if it is forbidden and if it is I will redirect the user and do some stuff (like remove the token from storage and redirect)...

Upgrading from tRPC v9 and NextJS v12. Should I upgrade NextJS first or tRPC?

I have an app built from the tRPC + NextJS + Prisma starter, and I'd like to upgrade from tRPC v9 and NextJS v12 to the respective latest versions. Does it make any different whether I upgrade Next or tRPC first?
Solution:
it shouldn't matter

prefetchinfinite not working when inputs are different

Ive been trying to figure out why prefetching doesnt work when the inputs are different between prefetchinfinite and infinitequery. Its works great when the inputs are the same. Hoping someone can shed some light on this. ``` export const getStaticProps: GetStaticProps< PageProps,...

tRPC + App directory + SSR - current state?

What is the current state of the technologies working together with or without SSR? It looks like some work is/was being done around using tRPC with the new app directory but its hard to tell if that work is completed or what is currently supported or recommended. Can I start a new Next.js project with the new app directory and tRPC and expect to be able to utilize SSR for the RSC (React Server Components)? What problems currently exist? If tRPC requests can't be handled during SSR at this point, can the RSC still render on the server but the tRPC query begin on the client on mount? ...

Hydration failed because the initial UI does not match what was rendered on the server

```Unhandled Runtime Error Error: Hydration failed because the initial UI does not match what was rendered on the server. Warning: Text content did not match. Server: "3/07/23" Client: "03/07/2023" ...

React tsc starts checking server types

My tsconfig files are different on the server and client. When I run "tsc" on react client, It is trying to check AppRouter types from the server. Is it possible to make him stop checking server types on compile?

NextJS 13 Build failing

Issue also seen in this PR  https://github.com/trpc/trpc/pull/4574 I found. None of the webpack workarounds seem to work for me to get it building again. Any updates on this?

Google OAuth callback

any one help how to handle google oauth callbackurl using tRPC

Infering query/mutation callback opts parameter

Hey 🙂 Thanks for your hard work on this awesome library. I want to create tRPC router, but i want to pass query (or mutation) callback from other part of the app. I am working with monorepo, and trpc router definition will be stored as a package shared by server (which will provide certain controllers implenetation) and frontend (which will infer type for queries & mutations). Unfortunately I don't know how to properly infer query / mutation parameter type: ...

Type helpers to match available paths

Given a router like this: ```typescript const appRouter = t.router({ post: t.router({ list: t.procedure...

Best way of handling recurring events through NextJs and tRPC

Hi, I'm working on a project that handles users' "bonuses" and I need to refill these bonuses every day (so, every 24 hours). The easiest solution that I was thinking uses sql events so that they would modify the users table periodically. However, I'm using PlanetScale which doesn't support stored routines (triggers, procedures, events...). What's the easiest solution to this problem with this stack? Probably cron jobs are the way to go right? What tech would you guys suggest using?...

Are GET and POST the only HTTP verbs supported?

I’d like to add a procedure to handle HTTP PUT.

Query param in every client request

Hi ! Im wondering if there is a way to add query params in every request without creating a custom fetch. I only need to forward one query param from the browser URL to the trpc where my procedures are hosted plus the authorization header. Would like to avoid adding a fetch middleware system. thanks!...