tRPC

T

tRPC

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

Join

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 http://127.0.0.1:3001/api/trpc/model.getAll?batch=1&input=%7B%7D. (Reason: CORS header β€˜Access-Control-Allow-Origin’ missing)'). how can I fix this?

T3 app tRPC external calls

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

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 according to Visual Studio Code intellisense...
Solution:
Had to add the superjson transformer

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....

How to not send request in specific condition in useQuery()

const { data: artists, isLoading } = api.findArtist.useQuery({
name: search,
});
const { data: artists, isLoading } = api.findArtist.useQuery({
name: search,
});
...
Solution:
enabled: !!search

TRPCClientError: fetch failed

I get the below error when createTRPCProxyClient runs on BE of a Next.JS app hosted on Vercel: ```TRPCClientError: fetch failed at TRPCClientError.from (file:///var/task/node_modules/@trpc/client/dist/transformResult-9a244fe7.mjs:13:16) at file:///var/task/node_modules/@trpc/client/dist/links/httpBatchLink.mjs:211:64 {...

inferRouterOutputs not inferring

Could anyone point me in the right direction to why my types aren't being inferred here? (Using T3 boilerplate)
No description

Modular Router Thoughts

Hello, I hope I can convey clearly what I hope to accomplish. To start, I have a monorepo, with a few frontends and lots of packages. some of those packages relate to external services. For instance @org/asana and @org/zoom I have another package, that is my big-ole-router that builds the trpc router and imports all those other packages, builds middlewares to add clients, builds procedures to scope each service.... This was great when I had the router mounted in a mega App I used to have, but now I am making smaller apps with more scoped features.......

Issue with trpc fetch when trying to pass Clerk auth to context

I'm currently trying to add Clerk auth to my trpc context, but I just keep getting this error: Error: Unexpected token '<', "<!DOCTYPE "... is not valid JSON This is my code: ...

BullMQ + TRPC

Curious how to configure BullMQ with TRPC correctly. Currently I have the queue, queueevents, and the worker inside a router. Though it works, I have a feeling its not the right approach?

Trpc refetches all of the queries when i run a mutation

Im running node 16.15.0 with Pnpm When i run a mutation for some reason all of the queries get refetched. Im using the app dir and rehydrating the client but I think it has nothing to do with the issue...

tRPC Client on NodeJS server keeps complaining that no fetcher has been configured

Hey, I want to create a tRPC setup where I have one server (works fine) and then a client which is created on another server. I create the client like this: ```...

Best Practice to Fetch a Query OnDemand

What's the best practice to fetch a query on demand? I don't have the context for the query's input in the scope of my component. (Using react-hook-form with a zodResolver that has a dynamic refinement based on the fields submitted and a components prop)...

Output Response Shape

I'm wondering, is the output response shape locked in, or can we modify it in any way? For example: ```json { "result": {...

Need help

```js import {initTRPC} from '@trpc/server'; import * as trpcNext from '@trpc/server/adapters/next'; import {z} from 'zod'; const t=initTRPC.create();...

useQuery hook modify data on fetch.

Hello is it possible to modify the data that is fetched with useQuery hook in tRPC basically im storing a json object as a string in the db but after i fetch the string i dont know how to convert it to json properly..

Accepting a DecoratedProcedure with inputs and outputs that extend some given types

Is there any way to accept a DecoratedProcedure that extends { mutate: Resolver<TProcedure> } where TProcedure is guaranteed to have its inputs be something that extend the object { nextFollowerId: string }, and the outputs are a string?

useEffect and useMutation error about conditional rendering of hooks

I am using t3 stack with tRPC, and I am trying to mark all emails as seen when the page loads by using useEffect, but this seems to give me an error about conditional rendering of hooks. Are there any other ways I can accomplish this? ```...

Guide to create an adapter

Is there a guide on the docs that explains the basics to create an adapter?