Questions tagged [trpc.io]

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.

https://trpc.io/

https://trpc.io/docs

124 questions
1
vote
1 answer

Exact types of trpc.useQuery first argument for a wrapper hook

I'm trying to make a wrapper around every call to trpc.useQuery. It should look something like this: function wrapper(pathAndInput) { const result = trpc.useQuery(pathAndInput) /* some code that also uses `pathAndInput` */ return…
Sheraff
  • 5,730
  • 3
  • 28
  • 53
1
vote
1 answer

How do I cache data for state management in Nextjs and tRPC?

I'm using tRPC to fetch my data to the client. tRPC uses React Query as a dev dependency so I got that installed too. Since my app is rather small, I'm choosing to not use Redux. I read that React Query can cache data using their QueryClient API.…
xmuhs
  • 96
  • 1
  • 9
0
votes
0 answers

@id @default(cuid()) not working in prisma

When I'm trying to create dayEvent trpc is throwing this error: TRPCClientError: Invalid `prisma.dayEvent.create()` invocation: Null constraint violation on the fields: (`id`) Here is trpc code that creates dayEvent: create: protectedProcedure …
Grayza
  • 53
  • 10
0
votes
1 answer

Nextjs 13.4.9 app router error in client component

I am getting this error in Nextjs it persists until I remove the 'use client' directive. Warning: Rendering is not supported and will be removed in a future major release. Did you mean to render
seven
  • 1,183
  • 14
  • 33
0
votes
0 answers

Unable to import enum to nextjs frontend from trpc backend in yarn worksapces monorepo

I have a "next": "13.4.9" app and "@trpc/server": "^10.34.0" on a backend I can import types from my backend to the frontend but when I import anything that would then run in the runtime I get error ../api/src/utils/functions.ts Module parse…
seven
  • 1,183
  • 14
  • 33
0
votes
1 answer

trpc `useSubscription` doesn't get React state updates

I'm building a Next.js app with trpc that requires real time comunication. It has been going well, especially since my useSubscription calls have only been updating state rather than reading it so far. I have a ContextProvider with some state which…
Gustavo Shigueo
  • 399
  • 3
  • 11
0
votes
0 answers

How can I create a root procedure in trpc.io using a magic token?

My idea is to have a root procedure that only can be called from the server itself (i.e: during calls from getStaticProps or getStaticPaths at build time). I want to set a magic token via env and protect a trpc procedure against this random…
0
votes
2 answers

Populating UseState value with trpc response

I'm trying to populate the UseState initial value to the values of my users first and last name according to the response I got from the tRPC api. const { data: sessionData } = useSession(); const { data: currentUser } =…
39fredy
  • 1,923
  • 2
  • 21
  • 40
0
votes
0 answers

tRPC Client-side Type Inference Issue with Nested Promises

I'm using tRPC for my TypeScript project and I've encountered an issue regarding type inference on the client-side. Here's the simplified code snippet from the server: demoCode: publicProcedure.query(async () => { return await Promise.all( …
Joshua Kravitz
  • 2,785
  • 2
  • 15
  • 15
0
votes
0 answers

Next.js SSR Load Times Over 10 Seconds

We're building a Web3 DAO platform which integrates Web2 functionality, and we need a server-rendered page for one main reason: server-side auth & role checks. From what I understand, there is no way of turning the SSR pages into ISR correct? as…
Herbie Vine
  • 1,643
  • 3
  • 17
  • 32
0
votes
0 answers

How to use multiple tsconfig files/project while sharing few types between the projects?

I have a following code structure: ├── frontend/ │ ├── tsconfig.json │ ├── src/**/*.ts[x] ├── shared/ │ ├── **/*.ts ├── server/ │ ├── tsconfig.json │ ├── src/**/*.ts ├── project.json There are already quite a few questions around the same…
Harshal Patil
  • 17,838
  • 14
  • 60
  • 126
0
votes
0 answers

Adding user to group by clicking button in email in trpc and nextjs

So I currently have a nextjs app that uses trpc and prisma. I had previously had a user able to invite another person to their 'household', by entering their email into a form, and a secret token would be generated and emailed to the person. They…
Mossy82
  • 115
  • 1
  • 9
0
votes
1 answer

Passing a react-query trpc query as a hook parameter

I'd like to make a generic hook that takes useQuery as a parameter and handles pagination. That means my trpc query will always provide a skip and a take parameter. And it will always return a count in the response and an array of items. function…
maxime
  • 1,993
  • 3
  • 28
  • 57
0
votes
0 answers

Writing dependent integration tests that interact with prisma

I have a trpc express server with a bunch or routers. Most of procedures require auth, and there I have the problem. I have already set up docker test environment with empty postgres (prisma) db, but vitest works in parallel, and I face conflicting…
0
votes
1 answer

React-infinite-scroll component not loading after initial data

I've encountered a rather frustrating bug where I at one point had the react-infinite-scroll component working properly and all was well, but while doing some styling I noticed that now it's only showing 'Loading...' and not loading in the next…
Mossy82
  • 115
  • 1
  • 9
1 2 3
8 9