Theo's Typesafe Cult

TTC

Theo's Typesafe Cult

Join the community to ask questions about Theo's Typesafe Cult and get answers from other members.

Join

Pagination for multiple items

Let's say I have 100 000 rows of data in my database and I have a REST API to query these. Obviously I can't query the 100 000 rows at once so ideally I want to have around 25 rows in my UI present and 25 on the next page and so on. Question is, how to do this in an efficient way? How to request the right amount from the server and so on Thanks...

nextauth deployed in gcp no_secret

Hi im currently deploying my app into gcp and somehow it keep saying NO_SECRET in the logs i tried setting up variables in .env with 1. NEXTAUTH_SECRET (and nextauth will automatically get the secret) 2. set custom variables like MY_SECRET then define it in [...nextauth].ts secret: process.env.MY_SECRET...

Can anyone share how to infer type of class member of trpcresponse

I am using inferRouterOutputs<AppRouter>['abc']['def'] to get the type of response, now I need to get the type of a member of output response , please share if anyone has done this before.

How do I make the grid or flex item grow to the size of the parent on click?

i have tried to make the other flex items hidden on click but I can't figure out how to animate it.

env Variables causing issue deploying to Vercel

Howdy! So I'm trying to host my CT3A on vercel. The build is failing, looks like it's the env variables that are causing the issue but I'm not sure what I'm doing wrong. I double checked that my schema.mjs file isn't missing any variables, and I actually did miss one, so I figured sure that must be it, but even after adding it to the repo, the build is failing for the same reason. This is my schema.mjs...

styling feedback pls

thoughts on the tilt for active page? just wanting advice, thanks

Hi, I am getting a hydration error and I am hella confused on why. I dont see any incorrect tsx here

I am trying to make a table but for some reason im getting a hydration error on this one page

How Can I Pass a Ref Down To A Child Component and Have It Not Just Be The Starting Value

Hello, I have a bit of a odd question and 99% of the answers for this I have seen are for class components and do not translate to functional components. I am essentially trying to do the following: ```ts...

Next Auth Production Issue

I have a web app using session auth of NextAuth for authentication. It works fine locally, however, when deployed to Vercel, it errors out when logging in via Email Provider or Credentials. I am getting this weird error: ...

add fields to session

I'm using Prisma and doing an initial query to get orgId from my User table before almost every query/mutation. Ideally I'd just like orgId to be included in my ctx/session so I can access it directly similar to ctx.session.user.id. I have orgId in my Session table already, but not sure how to map that to context/session. an example of a typical query: ` getLowInvWarnings: protectedProcedure.query(async ({ ctx }) => {...

Array with generic vs type[]

Using array with generic works but the same thing using type[] does not. anyone know why? thanks

Deploying to AWS Amplify

Hi, my company is wanting to deploy an internal T3 app, but hosted on AWS Amplify. I've seen various tuts on deploying Next.js apps on Amplify, but it seems that tRPC is not playing well with it. Does anyone have experience deploying to AWS Amplify, or otherwise have any suggestions? To preface, I've been told we cannot deploy to Vercel.

How to type storing JSON in Postgres with Prisma

I am storing a json array in postgres for a specific use case, and prisma types it is as Prisma.JsonValue. However, I know what the shape of this json will be. In their docs they recommend doing this (light mode screenshot). The issue is that Prisma.JsonArray is just a type saying its an array of other json stuff. How can I make it an array of an actual type I know? Ideally as Link[] would be good but I have to do as unknown as Link[] for that to work and it does not feel correct. Any ideas? Thanks ```ts...

REST API Error Handling

Curious if there is a standard best practice for laying out error handling on a simple rest api. How do you handle the error message on the frontend (does that come from the error response?). What is the general structure of using zod to check body shape and then all other error handling (nested try catches?) do u use safeParse on zod? I am trying to really clean up my code with full error handling and want to know what the best option is for it. Always been a minor point of confusion for me somehow. (Should I basically wrap the entire endpoint in a try catch and then nest more inside of it for specific errors? Should error messages come from the response or should it be a code and the frontend chooses the message, or something else??)...

Public folder from create-t3-app trpc router?

My google-fu is failing me! Can I access the content in the public folder from the API? I tried referencing it the way I would on the frontend ("/images/file/path.svg") and it doesn't seem to be able to see the files. I know I could append the domain, but I would like to access the files directly rather than over http....

best way to create a mobile experience for a webapp

I've been building a webapp for the last few months using create-t3-app with tailwind. The app is getting pretty big (codewise) at this point and its becoming more and more obvious that i need a real mobile experience. As far as I can tell there are 2 ways to do this. 1) Make all my components responsive so the same webapp works for all screen sizes. 2) Make a separate set of mobile components and create separate pages that use these versions. ...

[Solved] Conditional types

I was reading the TS docs but I can't seem to grasp this concept very well. I have the following interface: ```ts...

Can anyone share an example trpc mutation based onSubmit values from a form

I keep getting Hooks can only be called from React component.

Type Error while building

Hi guys, I am getting a type error of module not found, when I am building my next application: https://github.com/amantulsyan35/context can someone please help me with the issue here?...