tRPC

T

tRPC

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

Join

SyntaxError Unexpected token u in JSON at position 0 with mutations

I'm trying to use trpc client to await a mutation and just keep getting this error. everything works if i change the mutations into queries

Losing the type between the client and server

Hello everyone, I am new to tRPC and the magic of types in typescript so I am looking for ideas as to what is happening, the client is receiving any type instead of a string

Mobile app with tRPC

What's the suggested way of working with tRPC when it comes to mobile apps? How do you ensure that your CI doesn't let you push a new backend to production if it breaks the mobile app in production?

How to use trpc react hooks from an external data source

Hi, I have a monorepo, nextjs and keystone cms. The cms has trpc running, and I managed to get it connected to my nextjs. Is it possible for example to use the useQuery hook with that connection? Atm I use
createTRPCProxyClient
createTRPCProxyClient
from "@trpc/react", but it seems to be the same as I would import it from "@trpc/client". See screenshot Thanks for any help! 🙂...

V10. How to infer types on V10?

https://trpc.io/docs/v9/infer-types I am trying to infer types to use the inputs on my yup forms in the front end but can't get this working and did not find an example docs for that. The current example available at https://trpc.io/docs/v9/infer-types is depreciated on v10. ...

NextJS & Keystone CMS, issues when connecting both in a monorepo

Hello everyone, so I have a monorepo with NextJS and keystone cms, both are running trpc v10beta.15. Screenshot 1: I receive a type error when trying to use the CmsAppRouter type in my NextJS when calling createTRPCProxyClient....

Best practices for implementing an offline application

Hey there! I'm building a full stack react-native app with Expo and a tRPC backend. I'd like for this app to be functional offline. Currently I'm accomplishing this via a simple optimistic update like: ``` const createUser = trpc.userCreate.useMutation({ onMutate: async () => {...

somehow when move typed function out of the router files, frontend infer type to be any ?

this is inferred corrected since they are in the same file. ``` getX: t.procedure.query(() => { return getX() }) ...

Big companies that use tRPC?

Some of my fellow colleagues were wondering if there are any big companies that use tRPC and how mature you would say it is for production in "real" projects?

SSG on nextJS when appRouter is made with fastify adapter?

```js export const getStaticProps: GetStaticProps = async () => { const ssg = await createSSGHelpers({ router: appRouter //This app router is in fastify ctx: await createContext(),...

Migrating to V10 from V9

If someone has some ideas on what I might have screwed up when trying to bump tRPC for this public starter please let me know. https://github.com/chamatt/create-kaol-app/pull/7/files...

Authentication broke after bump to v10 from v9

Anyone that has any suggestions on what might have caused this? I get the following error when trying to sign in or sign up.: ``` "Cannot use 'in' operator to search for 'auth.signUp' in undefined"...

Show a spinner when any mutation is loading?

Looking to show an activity spinner in the header of our application whenever a mutation is in flight (Hoping this will be easier than showing it in every conceivable place to say that your request is loading). There might be a few ways to do this, but any recommendations for minimal boilerplate?...

Sharing schemas between server and client

In a typical nextJs setup, what is the idiomatic way to share zod schemas between frontend and backend? Suppose the following use-case: we have a mutation that takes an input: ...

v10 Migration interop, router doesnt have attributes

Hi, i've tried to migrate like stated in the docs, these are my routers. Question: Shouldn't appRouter now have access to the merged routers above?

Recommended file structure for next.js?

Hey all - using tRPC heavily with next.js and it's great. Our main [trpc].ts file is getting huge and unwieldily - wondering what the recommendations are out there for organizing?

Unhandled Runtime ErrorTRPCClientError

Call Stack Function.from node_modules@trpc\client\dist\TRPCClientError-09b8a26b.esm.js (57:0) transformRPCResponse node_modules@trpc\client\dist\httpRequest-62c5cce4.esm.js (15:11)...

Weird error when running unit test

10.0.0-proxy-beta.5 works just fine, error occurs on 10.0.0-proxy-beta.6 with the introduction of @swc/helpers.

Sharing middleware between TRPC servers

We currently have microservices REST API's on Cloudflare Workers and I'm thinking about moving this to TRPC Microservices. We currently have a middleware in a shared package that we can reuse between microservices for authentication, how do I do this within TRPC? How do I define a MiddlewareFunction that can be reused between multiple TRPC instances?...

Is `trpc.withTRPC` for Next supposed to work with pages or only `_app`?

I'd love to only have TRPC mount on certain pages of my Next.js app. Is this currently supported?