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

Why is this re-rendering infinitely

This block of code is causing infinite re rendering causing the app to crash with this error in console: Unique constraint failed on the constraint: PRIMARY...

Unable to invoke prisma mutation to planetscale dev branch.

Dev branch was created on planetscale and the env variables are set to dev branch values.
npx prisma db push
npx prisma db push
works fine and succeeds. Looking at planetscale the new tables/fields are created but when I go to try to invoke the prisma mutation I get the error:...
Solution:
(restarting the application again after
npx prisma db push
npx prisma db push
)

next13 app dir - multiple route handlers in one folder?

Is it possible to have multiple route handlers in the app/api dir in the same folder? It seems like it would get out of control pretty fast if you need to create a folder for each route… Compared to trpc for example where you could have multiple routes under a common path. You can do so with appDir route handlers but you’d have so many more folders and files… is this the only way or can you avoid all these folders for each route?...

Invoice PDF to JSON output

Has anyone come across a library that extract information from invoices (pdf input, json output)? Something like https://mindee.com/, but open source?

Multi-tenant Saas Application

Hi guys! I don't how best to implement this but basically I'm trying to create a saas application that is 3 levels deep. By this I mean, There is a master admin that manages the organizations/tenants, The tenants will have normal users or they might have teams, then Teams would have Team members and team admin. This is quite a lot for me and I don't know where to start. I'm planning to use next-auth btw. Thank you so much for any kind of help!...

Turbopack

Does T3 use Turbopack under the hood?

How to let 2 types of users to login to my app - customers and businesses

I'm using Clerk rn but I'm down to switch to NextAuth if it works better for this. I just want to let customers and businesses sign up to this website - and they see different stuff when they login. I ask businneses more questions on signup and store that in a table (customer data on another table) How would I even manage this? Do I let states manage this? (don't think this is correct)...

Fastest way to get counts (need to redo schema?)

So I have a dashboard page, where the general details for each course are displayed on their card. The api route I had to write for this is taking over a second every time to run (sometimes like 3 seconds). I have to make queries that calculate the stuff I want to show because they are not ready on any given table. How do I fix this? Do I have to remake my schemas and try to keep this info ready instantly on the course table? (You can see I have to get the courses someone is enrolled in, and then loop over those to do the calculation for each - very slow). Thank you!...

Collect user's name on sign up form using NextAuth.js Email Provider?

Hi all 👋 How do I collect a user's name at the outset of a sign up flow when using the Email Provider? E.g. from a typical sign up form like the attached? As far as I can tell, this can't be accomplished by using the configuration options (https://next-auth.js.org/configuration/options), Email Provider options (https://next-auth.js.org/providers/email) or Callbacks (https://next-auth.js.org/configuration/callbacks) detailed in the documentation & requires a deeper level of customisation....

T3-create-app: new update whit: Drizzle/shadcnUI?

Does anyone know if there will be an update to the T3 stack to include: - drizzle/PlanetScale - Next.js new App dir - shadcn UI components ...
Solution:
Does anyone know if there will be an update to the T3 stack to include: - drizzle/PlanetScale - Next.js new App dir - shadcn UI components ...

In create-t3-app how to get tRPC zod schema on client?

I know we have RouterInputs to get the input type, but can we get the zod schema to validate things on the client? Of course we could just export the schema from each router file and import it in the client, but I imagine something like this would be very ergonomic: ```tsx import { useForm } from 'react-hook-form'; import { zodResolver } from '@hookform/resolvers/zod';...

Best way to handle env variables in nextjs 13

So we need to go further than the standard dev/test/prod env variable options, for instance we have 3 different staging environments that all use different endpoints. What would be the best way to handle this? I've done some research and have found several options, but I was wondering if anyone has hands-on experience with this scenario and can recommend an approach.

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

TRPC function type per router

I know you can run your TRPC endpoint on vercel's edge, but does anyone know if I can run some routes on serverless and some on edge? Thanks

Make NextAuth consider i18n

I am defining a custom sign-in page in my app setting ```typescript pages: { signIn: "/auth/login", }...

How to SSG a page from my T3 app??

I have been following this documentation: https://trpc.io/docs/nextjs/ssg So I have a [chat].tsx route and I put this in the page component: ```tsx import { createServerSideHelpers } from "@trpc/react-query/server"; import {...

Passing a object with readonly attributes through tRPC

I have a class (provided by a library) ```TYPESCRIPT import { Asset, GameMode, IMatch, MapName, Participant, PlatformRegion, PubgAPI, Roster, SeasonState, Telemetry } from '..'; export declare class Match {...

Prisma with kysely

Hi, I am using prisma to create schemas and some queries. I know prisma can be slow in serverless function so I was thinking to use kysely for the queries that need the speed. If I have prisma in the trpc context and do not use it will it create a connection? I think not but I want to be sure. So if in some functions I use kysely to query would it make a difference?...

Passing data as props in form function

Hi fam how can I pass props on a form function below is my form function ``` const handlesubmit =(e:React.FormEvent ) =>{ e.preventDefault()...