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

Join Server

Community questions


How does trpc subscription actively close/disconnect in the server?

How do I actively disconnect my subscription?
JHjeff h6/3/2023

child router question

let's say we have a monorepo, one server, two client apps (cat and dog). we make one appRouter, like:
export const appRouter = t.router({
cat: catRouter,
dog: dogRouter
export type CatRouter = typeof catRouter;
export type DogRouter = typeof dogRouter;

the cat app should only know about cat routes, dog app only about dog routes by importing the right type.

the server will listen for /cat.getCatFood and /dog.getBone. either i want to change the dot to...

How to force SSL on projects using tRPC?

Hello everyone,

I'm working on a project that uses create-t3-app as boilerplate. My project is hosted on heroku. I have an issue with forcing HTTPS connection. Before tRPC, I was able to solve this issue by using express-sslify like it was explained in this post on Stack overflow https://stackoverflow.com/questions/67490760/how-to-enforce-ssl-on-a-node-js-app-on-heroku


AWS Lambda / How to set Cookies inside Procedures

How can I set and remove cookies similar to ctx.res.cookie(..) with Express when using the aws lambda adapter.

My configuration is:
* node 18
* tRPC 10
* aws lambda adapter / APIGatewayProxyEventV2

I do not need CORS - I only need to write/delete Cookies

I tried awsLambdaRequestHandler but was not able to access anything I added to context in my procedure to be visible there.

Thank you for the support and this great tool!

Massive Type Errors on tRPC 10 Legacy Router against MergeRouter

We're trying to upgrade to tRPC 10 but I am running into a massive type clash when trying to merge routers. Our tRPC 9 router is huge.

I've interop'd all of these routers and the legacy router itself, but when I get to the point at which I am merging my new router with my old legacy router, my .merge statements on my legacy router blow up a massive illegible typescript error.

Attached is a glimpse, can provide more info if necessary

Is it possible to create 2 routers inside a single file?

I am having an issue in which it is impossible to me to use a class instance within 2 routers. I tried declaring the routers in a single file and then exporting them, it doesn't work. The issue I am facing is this: https://github.com/vercel/next.js/issues/49309

Any insight/help would be greatly appreciated.

Use onError to change an application error into a TRPCError?

I want to use the onError handler to change any instance of a custom application error into a TRPCError (I want the HTTP Status code to be a 401 rather than a 500). I tried this but it doesn't work...
  onError({error}) {
    if (error instanceof AccountLimitError){
      error = new TRPCError({ code: 'UNAUTHORIZED', message:error.message })

nor does this
  onError({error}) {
    if (error instanceof...
KMJKarate Man Johnson6/1/2023

Increasing Body 1mb limit

Hey, Im trying to build an application that allows sending of base64 encoded files to my next.js server through TRPC. I read online that the only currently supported way to do that is by base64 encoding and then shipping it over through JSON. Is there a way to increase the default 1mb limit on post requests? For my purposes 2-4MB would be more than enough But i am expecting a few at > 1mb filesize.

Nitro and tRPC in vercel-edge

Hey there! I hope this is the right place to ask for help.
I am trying to deploy an application with Nitro and tRPC with the vercel-edge preset.
I am getting a weird proxy error when I deploy it without making any changes to how tRPC is handled.

TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property 'setTimeout' which is either non-existent or configurable in the proxy target
    at (index.mjs:1:126...
F|FAfrankind.eth | Franco Aguzzi5/31/2023

How to retrieve and receive Bigint data to/from TRPC procedure

Node: v16.15.1

I'm trying to return an object which contains an amount property from one of my TRPC procedures... This property should retrieve a bigint. Unfortunately, I'm receiving error:

TypeError: Do not know how to serialize a BigInt

When doing this. I've already configured superjson Data transformer in my TRPC server instance creation and in client's createTRPCNext's...

React Router Loaders + tRPC?

In Vite project: would it make sense to use React Router loaders with tRPC? I like more the concept of RR Loaders than React Query, but Loaders don't seem to have typesafety, and there are no tRPC adapters, right?

TypeError: Cannot read properties of null (reading 'useContext') when using useMutation with TRPC in

I'm encountering an error in my Next.js application when trying to use the useMutation hook with TRPC (Typed RPC) library. The error message I'm getting is "TypeError: Cannot read properties of null (reading 'useContext')". It seems to be related to the useContext hook, but I'm not sure how to resolve it.

Here's the relevant code snippet within a Next.js component, including the TRPC setup:

/// trpc router
import { api } from "...

Initial websockets getToken() returns null: next-auth + websockets :)


So the way I am trying to authenticate websockets is like this:

import { getToken } from "next-auth/jwt";

type Incoming = IncomingMessage & {
  cookies: Partial<{ [key: string]: string }>;

export const createTRPCContext = async (
    | CreateNextContextOptions
    | NodeHTTPCreateContextFnOptions<IncomingMessage, ws>
) => {
  const { req } = opts;
  const token = await getToken({ req: req as Incoming });

JHjeff h5/29/2023

Can I get the original type name, instead of the shape, with query?

I'm not sure how to explain it, so, here's a screen shot:

TRPCClientError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON Error

Hello folks, I'm getting an issue with my integration, I'm a newbie in tRPC and I can't work well my integration with next, next-auth, and Prisma to make an authentication.
When I'm doing the request to the server, (I think) I'm receiving the following error

failed to load resource: the server responded with a status of 404 (Not Found)

And also the error in the image.

trpc cors

my sveltekit app is running on https://example.com with tRPC and it's making requests to http://127.0.01:3001/api/trpc (otherwise it won't work) but I'm getting a CORS error (' The Same Origin Policy disallows reading the remote resource at (Reason:...

T3 app tRPC external calls

Currently i'm just making Post request and formatting my payload to
    "0": {
        "json": {
            ....data <--- actual data.

format. It works.
Saw that people use trpc-openapi for that. Is it really necessary? What are downsides of my approach?

Next-auth session not being fetched in tRPC context

Next-auth session not being fetched in tRPC context

useMutation not handeling arguments correctly.

Hello, I have a mutation setup on the server with the input being an object containing the fields email and password. I am using the TRPC HTTP server on the backend. The request data is {"0":{"email":"dev@dev.dev","password2":"test"}} and the response complains about receiving undefined instead of object. I'm using Zod for input schema.
Furthermore, the useMutation arguments are any acco...

Update Clerk Organization from TRPC Router (T3 Stack)

Hello, if anyone got an idea on how to handle this I would highly appreciate it.

I have some organizations in my app and I have stored some information on the publicMetadata.

I have a settings panel where an admin user will be able to change this information.

I have read https://clerk.com/docs/nextjs/trpc as well as setting up the context like this project

© 2023 Hedgehog Software, LLC. All rights reserved.