How does trpc typing work
I'm curious to know how trpc generates type without a code gen step , i am trying to acheive something like this
```ts
export class API {
private schema:z.ZodSchema = z.undefined()...
Globally handle specific Error type on backend
Hi, i have a lot of code that's used for both backend and frontend.
That's why i'm not throwing TRPCErrors but custom errors instead. They indicate that the error message should be sent to the client if it arises on the backend (on the frontend this obviously doesn't matter).
Can i set up the tRPC server side in a way where it will catch all errors so i can do something like this?```ts
if (error instanceof DispatchableError) {
throw new TRPCError({...
Solution:
Error formatter is correct, you can omit data or enrich data in there for all your needs 🙂
How to use token in headers() ?
in
_app.tsx
i have this ```import React from 'react';
import { trpcApi, trpcApiClientProvider } from '../common/api';
import { reactQueryClient } from '../common/reactQueryClient';
import { QueryClientProvider } from '@tanstack/react-query';...Creating inner context for AWS Lambda Context Options
Hi All,
I have been using tRPC for many routes, and I have started to realize I need to call certain routes on the server-side (lambda / serverless in my case), and so I was trying to follow the documentation on how to create an inner context / outer context so I can call my tRPC routes from other routes, but I am stuck and I am confused on how to go about doing it for AWS lambda context as the documentation example is rather simple.
This is what I have so far:...
Retry even when disabled
I'm not positive if this is a tRPC question or Tanstack.... but I have my query disabled per Tanstack docs and it fires every time the page is focused if I throw a TRPCError. Anybody have any ideas on what I'm doing incorrectly?
Solution:
It's a tanstack thing, refetchOnFocus as well as a few related options

Middleware or request lifecycle hook to run after procedure?
Hi,
I am using trpc context to create a database client for an incoming request. My understanding is this runs for every request, which is what I want.
I want to be able to systematically close the databaase client at the end of any TRPC request. Is there any way of doing this? Perhaps with a middleware or request lifecycle hook? I couldn't find any documentation on it....
Solution:
is this sort of what you mean?
```
const withDb = middleware((opts) => {
const db = getServerlessDBInstance();...
Use RxJS Observable for subscription procedure
On the server, I have an RxJS Observable that I'd like to use for one of my subscription procedures. Is this possible without writing a converter function that takes an RxJS Observable and converts it to a tRPC Observable?
For example, what I'd like to do looks something like this:
```ts...
Individual mutation requests error
Hello, quick question regarding the error handling for tRPC
So I'm creating kind of a chatroom where I use a combination of tRPC and Pusher to send and receive messages. I'm currently stuck though when sending multiple messages (where I'm assuming they get batched in some sort of way) and then one of the requests fails for something like ratelimiting which I will display as first send and then an error.
However, multiple of the other messages that get batched together are never gets their response, leaving them in an infinite sending state (see screenshot below)...

TRPCClientError: fetch failed, using Node 18 in Docker
I have both my app and my tRPC server running in Docker via the following docker-compose config: ("navis" is the tRPC server, "retro" is the app)
```yml
version: "3.9"
services:
retro:...
Solution:
well I don't know how I missed that but noticed it when replacing the environment variables with the values while writing that message, I have to start with
http://
even when using docker networksNeed help how to send headers in trpc
project is setup with express on 2 parts,cleint and server
i have this pice of cod in client side ``` const { mutate: mutateCreateUser } = trpcApi.register.register.useMutation({
onError: (error) => {
const errorMessage = error.data?.httpStatus === 409 ? error.message : 'Passowrd must contains 6 characters';
if (errorMessage) {...
"fetch failed" when building
Hi, we are running into an issue where building our production next app causes "fetch failed" errors for every page that is being generated. We have ssr set to false.
How can we debug this?
```ts...
Looking for an up to date boilerplate for tRPC & Fastify.
Looking for an up to date boilerplate for tRPC & Fastify.
Can You Provide Guidance on Implementing RBAC and Share GitHub Examples?
I am currently exploring the implementation of Role-Based Access Control (RBAC) and am seeking your guidance.
Could you kindly provide insights, examples, or direct me to relevant GitHub repositories showcasing effective RBAC implementation?
Your expertise and assistance would be highly appreciated....
`useQuery` not working?
is it just me or does
useQuery
not work in my next js components?
i try to call it and it says client[procedure] is not a function...Solution:
Only applies if you're using t3 with app router:
If you're trying to use API in a client component then API needs to be imported from /trpc/react
If you're using API in an rsc or anything on the server, you import from /trpc/server...

Server Component Call to TRPC on express backend
I have following structure:
- Nextjs App folder with both client components and server components
- TRPC on express backend.
Communication with client components works perfectly, but I would like to call it from the server components as well. What is the correct approach?...
Can set cookie with trpc?
I tried to create a full authentication system in trpc using jwt and refresh token
I find that is not quite okay to create authentication with trpc
Can you suggest me a better way how I can achieve authentication in trpc project ?...
trying to understand how this works
so i'm looking at the t3 template that was made for me, and there seems to be a
trpc
folder that creates the trpc proxy client and such along with server/api
which actually defines the method
in that case, what's the use for the api route? it seems to me like i'm initialiting trpc twice, basically...can't call nested route
this is the top level router:
```ts
const appRouter = router({
hello: procedure.query(() => 'hello world'),
chess: chessRouter,...