Use this tag for tRPC, the TypeScript library for defining and using type-safe APIs for use with TypeScript servers and clients. For Remote Procedure Call, use [rpc] instead.
Questions tagged [trpc.io]
124 questions
0
votes
1 answer
TRPC Test Wrapper for unit and integration testing using jest and react testing library - client mock
How do you mock the TRPC client for unit and integration testing using jest and react testing library?

Ayo D Adesanya
- 43
- 6
0
votes
2 answers
Trying to code using tRPC and T3 stack with no internet connection
What about tRPC or the T3 stack breaks when trying to code offline? My console.log gets called when online, but when I try to code offline the procedure doesn't get called.
router.ts
export const exampleRouter = router({
hello:…

John McNeill
- 143
- 1
- 12
0
votes
1 answer
How to customize the JSON serialization in TRPC|zod
Is there a way for me to show TRPC how to serialize bigint?
I'm turning BigInt into JSON by
BigInt.prototype.toJSON = function() {
return this.toString()
}
And now the issue is when TRPC and Zod validate the big int it fails because its a…

Luis Angel Perez
- 23
- 5
0
votes
0 answers
How to Use z.discriminatedUnion() in TRPC?
Just getting used to trpc. Say I have a standard procedure:
update: t.procedure
.input(z.object({
id: z.string(),
type: z.string(),
content: z.object({ title: z.string() }).nullish()
}).nullish())
Now what I am interested…

antonwilhelm
- 5,768
- 4
- 19
- 45
0
votes
0 answers
NextJS tRPC Typescript errors: Argument of type X is not assignable to parameter of type 'void' / Type X is not assignable to type 'undefined'
I had typescript strict mode set to true and these errors weren't coming up in VS Code but when I went to deploy to Vercel it picked them up and the build failed. I then turned strict mode off and these errors showed up in a number of locations in…

Karumu
- 15
- 7
0
votes
3 answers
How to use "onSuccess" in useQuery in tRPC v10?
I am checking out trpc with t3 stack and I want to update a state when useQuery is successful.
and I am getting typescript error on the frontend,
Argument of type '{ onSuccess: (shoppingList: ShoppingItem[]) => void; }' is not assignable to…
0
votes
1 answer
How to get the name of the Tool's ToolCategory?
So I have a PostgreSQL schema written in Prisma, which looks like this:
model Tool {
id String @id @default(cuid())
name String
description String
url String
documentationUrl String?
user…

Király Roland
- 141
- 2
- 9
0
votes
3 answers
Cannot access the user-object in tRPC createContext (express)
I'm having an issue where my tRPC-configuration cannot access the express session on the request object.
I am using passport.js with google and facebook providers, and on any normal http-route (not on the tRPC router), I get the userinfo when…
0
votes
1 answer
Hydration Error in Next.JS with Trpc / React-Query (even when not displaying the pulled data)
const Home: NextPage = () => {
const [filterPublishedPosts, setFilterPublishedPosts] = useState(false)
const { data, isLoading } = trpc.item.getAllPosts.useQuery({
text: "from tRPC", filters: {
filterPublishedPosts:…

antonwilhelm
- 5,768
- 4
- 19
- 45
0
votes
1 answer
Converting circular structure to JSON error on tRPC
Using the t3-stack (Next, tRPC, Prisma, Next-auth, Typescript)
tRPC failed on undefined: TRPCError: Converting circular structure to JSON
--> starting at object with constructor 'RequestHandler'
| property 'client' -> object with…

gabrielforster
- 31
- 5
0
votes
1 answer
How do I use Zod's isEmail?
Not sure how isEmail is intended to be used?
.mutation("add", {
input: z.object({
email: z.string().min(1).isEmail(), <----- ? this doesn't seem to work / throws an error
}),
async resolve({ ctx, input }) {
let user = await…

antonwilhelm
- 5,768
- 4
- 19
- 45
0
votes
1 answer
How to properly use context in tRPC?
Let's say I have a very basic API with two sets of endpoints. One set queries and mutates properties about a User, which requires a username parameter, and one set queries and mutates properties about a Post, which requires a post ID. (Let's ignore…

scatter
- 903
- 7
- 24
0
votes
1 answer
Node.js pass data to route using typesafe trpc
I have a end-to-end typesafe api using the T3 Stack and I am able to access all the data and types through my Next.js app. But I also have a Node.js backend that I use to populate my database with.
My Node.js Settup looks like this:
app.use(
…

PEPEGA
- 2,214
- 20
- 37
0
votes
1 answer
Updating/mutating a session with next-auth and tRPC
I am building a multi-tenant NextJS app that uses next-auth for account authentication, tRPC for API's, and postgresql for a data store.
I am trying to find a way to dynamically update/set/mutate a session value based on some client-side…

tdc
- 5,174
- 12
- 53
- 102
0
votes
0 answers
How to create conditional types in typescript?
So I have a Form component in react which takes props to handle various different situations. As I am using it for an online store it will mostly be sending input data to the server, and it needs to work with zod and infered tRPC typings. and I made…

Joseph Walker
- 80
- 7