zendev
Explore posts from serversTTCTheo's Typesafe Cult
•Created by zendev on 11/8/2023 in #questions
Building shadcn <Form> components for string arrays?
So I know it uses react-hook-form under the hood, but I'm struggling to figure out the best pattern for building the form for an array. Say I had a form schema like this:
I want to create multiple <Input /> components that should each correspond to a certain element in the "socials" array, but how would this work using shadcn <Form> components?
This doesn't work, it throws an error saying "expected array, received string"
5 replies
TTCTheo's Typesafe Cult
•Created by zendev on 10/6/2023 in #questions
Best practice for providing current user from db to all react components?
So I know that various auth providers have hooks like useUser() or useSession() which you can use to access their user object in components, but I have a users table where each user has an extensive amount of data describing them.
I personally use supabase with the T3 stack, and I don't want to copy all this data to the "user_metadata" that supabase provides just to have the useUser() functionality.
So my question is: what's the best practice for providing current user data (from the users table in db) to all react components for the purpose of stuff like conditional rendering?
(I've thought about state management solution, or just plain old useContext(), but then how would you trigger refetches when the user changes something?)
9 replies
TTCTheo's Typesafe Cult
•Created by zendev on 8/23/2023 in #questions
Alternative to Clerk for cross-platform app (Next.js / React Native + Expo)
I’m looking to build a cross-platform app (web + mobile) and I love the DX that comes with the t3 stack.
Ive seen the turborepo templates but one major issue sticks out to me: create-t3-turbo doesn’t seem to have an auth solution for RN + Expo, and the other template forces the use of Clerk.
Yes Clerk is a great product, but their pricing is insane for anything consumer-focused (lots of MAUs) so what are some viable alternatives for handling auth across web + mobile?
11 replies
TTCTheo's Typesafe Cult
•Created by zendev on 8/15/2023 in #questions
tRPC SSG Helper w/ new Clerk middleware
So my goal is to do almost exactly what Theo does in his tutorial using the SSG helper for profile pages, but due to updated Clerk middleware I had to change my trpc.ts file.
I have my trpc.ts file set up identical to this:
https://github.com/perkinsjr/t3-app-clerk-minimal/blob/main/src/server/api/trpc.ts
There is a comment in there that says:
But I can't figure out how to use the "auth" object in the context when defining the SSG helper, it's always erroring when I try to set it up:
5 replies
TTCTheo's Typesafe Cult
•Created by zendev on 8/1/2023 in #questions
How to create debounce search with tRPC
So I'm aware that react-query provides a useDebounce hook but I guess tRPC doesn't wrap around this - so I'm wondering, what is the optimal way to create a simple search bar function with tRPC?
If I have something like this:
How do I add debouncing functionality so that the query only fires after a set time interval? As far as I can tell, tRPC queries fire instantly unless you set the property, but that only accepts a boolean.
5 replies
TTCTheo's Typesafe Cult
•Created by zendev on 7/6/2023 in #questions
How to use Prisma model type in tRPC mutation w/ Zod
I have some models defined in my schema.prisma file. Let's say they look like this:
I am using a tRPC mutation to create an "Art" in my Planetscale database. So, since I'm using Zod, I am doing something like this:
I know I can get the Creator type from Prisma, but I don't know how to tell Zod to expect those properties as the input so that the tRPC procedure will run. I hope I'm explaining this ok because it's kinda hard to put into words lol
7 replies
TTCTheo's Typesafe Cult
•Created by zendev on 6/29/2023 in #questions
tRPC query gets the type right on the way in and wrong on the way out?
6 replies
TTCTheo's Typesafe Cult
•Created by zendev on 6/28/2023 in #questions
Clerk - can’t get types of unsafeMetadata properties on user object?
I have some unsafeMetadata stored on the user object for users in my t3-app. When I try to access any property of the object, TypeScript seems unable to get/infer the type of that property.
So for example:
user.unsafeMetadata.stringProperty
should be a string but it comes back as unknown.
Is this a known issue or am I not doing something right?
5 replies
TTCTheo's Typesafe Cult
•Created by zendev on 4/23/2023 in #questions
tons of eslint errors in vercel builds that don’t show up in dev
I haven’t changed the default eslint config file that comes out the box with create-t3-app. Whenever I deploy to vercel, the builds always exit with many @typescript-eslint/… errors that I just don’t see anywhere during development. Anyone know how to fix this so that these errors show up during development and on local host?
1 replies
TTCTheo's Typesafe Cult
•Created by zendev on 4/19/2023 in #questions
File storage with T3
Hey so someone asked this before but it was half a year ago so I’m interested in seeing if things have changed:
I’m looking for a cloud-based file storage option for storing image and audio files for my app. Metadata for both will be stored in Planetscale but I need something for the actual files. What do you guys recommend?
48 replies
TTCTheo's Typesafe Cult
•Created by zendev on 4/1/2023 in #questions
P1001 Error with Prisma trying to reach database server
I’m following Theo’s T3 tutorial but when trying to do ‘npx prisma db push’ I get an error saying
P1001: Can’t reach database server at ‘aws.connect.psdb.cloud’:3306
I can’t figure out if it’s an issue with planet scale or prisma and couldn’t find anything helpful online. Thanks in advance for any help
1 replies