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

next export

Hey all, I’m trying use next export to convert the t3 starter website into a static site. I’m getting the error “i18n support is not compatible…”. Anyone got any advice?

Prisma Next-Auth PlanetScale foreign key constraints are not allowed

I am following the official docs to setup next-auth with prisma: https://next-auth.js.org/adapters/prisma. After copying these models (Session, Account, VerificationToken) into my schema.prisma I get the following error when I try to do a prisma db push. Am I missing something? How do I correct this issue? https://stackoverflow.com/questions/74769279/prisma-next-auth-planetscale-foreign-key-constraints-are-not-allowed...

nextAuth working only locally (not on vercel deployment)

I've been trying for a day now. I don't know the issue. I can't even get an error. When the nextAuth singIn() method runs, I just get the /api/auth/error page.

how does NextJs know what code to run on the backend vs frontend?

I thought only things in the API folder in Pages are ran on the backend, but there's a server folder in create-t3-app for the backend stuff Would someone explain to me?...

Zod discriminatedUnion

Hi guys, I have na union type as follows: ``` ts sections: z.array( z.discriminatedUnion("sectionType", [ z.object({...

.env has never worked for me

Any suggestions? Am using t3 stack I put in some keys in the .env when i try to console.log them it says undefined...

How to filter the SpaceX API (mongoDB find() based) by a nested array?! Tech Test

I'm stuck on a tech test where I need to call the spaceX API and filter all launches in the response based on an array of payloads including a specific nationality string. The the response normally has only a list of payload ids, but the full payload data is populated via options object. Link to API docs: https://github.com/r-spacex/SpaceX-API/blob/master/docs/queries.md ...

tRPC prefetching for Electron app

Hey 👋 I have a pretty basic Electron app, where I use tRPC to communicate with the server. I'd like to prefetch all the endpoints I'll need and display a loading screen, so that once the app is loaded the isn't any loading between switching pages. I saw that tRPC has a prefetch API for NextJS, is there something similar I could use in this situation?...

Tailwind stop popuop from flowing off screen

I have a dropdown component, and when the popup comes up when the main button is close to one side of the screen it flows off the page. I want it to get "bumped" over so it touches the side of the screen when this is the case

Is my approach correct to publish posts as 'published .. time ago' and SSR or tRPC?

I want to get my posts from SSR and what is the best way to get them? Can I use tRPC route calls inside SSR or should I call the prisma client from SSR?

Anyone know how to fix this typescript issue?

I'm trying to connect taskId to an existing task table but I'm getting an error that says: Type '{ connect: { id: string | undefined; }; }' is not assignable to type 'string'.ts(2322) It is a one to many relationship (many tasks on a list). ...

Zod like parser in typebox

Hey, I have a schemas made using @sinclair/typebox and I am looking for a similar option to .parse method provided by zod that throws an error. I see that @sinclair/typebox offers .Check method but it does not throw an error. Also there is an .Errors method that returns me an array of validation error but still I'd have to throw it manually. Am I missing something there?...

T3 stack issues with auth

Getting the following error. I can't find any resources online for it ```[next-auth][error][adapter_error_getSessionAndUser] https://next-auth.js.org/errors#adapter_error_getsessionanduser Cannot read properties of undefined (reading 'findUnique') { message: "Cannot read properties of undefined (reading 'findUnique')", stack: "TypeError: Cannot read properties of undefined (reading 'findUnique')\n" + ' at getSessionAndUser (/home/hycord/code/typescript/web/banappeals/node_modules/@next-auth/prisma-adapter/dist/index.js:24:52)\n' +...

How to make MUI TimePicker use UTC? (I really need this help)

Hi guys, I've been killing myself trying to do this, and I would really appreciate it if someone could help me, because I'm going crazy and I have to do this asap.... I know a lot of you guys hate MUI, but if anyone can help me, please do. I'm using a time picker, and I need that time picker to always show time in UTC to be in sync with the backend etc. I'm using a dayjs adapter. This is my code:...

Server vs client components

I am building an app that lets users create an offers just like on amazon. Is it a better idea to fetch those offers on client side or server side? Or it depends on the scale of an application?

Question about React architecture and organizing files

Hi there! I recently finished a project with a team in which we used MUI for the styles. The project turned out working perfectly fine, but I wasn't really happy that we ended up with files of 200 300 lines of code. I think that MUI doesn't help since when you declare the styles, prettier makes each property a different line so you end up with a <Box> that is 10-15 lines long. This plus the logic of that component made these files big. Now, I have two questions regarding this: - Should I create more components when the file gets too big, even if that component is not reusable? For example, let's say that I have a certain section of the page that is unique but is also very big, is it okay if I create multiple components for this section even if those components will only be used there? This would be in order to keep files more concise and organized - Is it okay to abstract the logic of a component in a custom hook even if that hook is not reused later? So let's say that I create a custom hook to handle a certain form with some specific inputs, and I want to control those inputs in a way that is incompatible with other forms in the application. Is it bad practice if I create a custom hook that won't be reused later on? Just for the sake of abstracting the logic of a component and just importing the necessary things from the custom hook. This with the idea that will separate the concerns of the files and help in avoiding big 200 - 300 lines of code files. Hopefully my questions were clear and not too newbie for this discord! Thanks ❤️...

Good idea to mix prisma and trpc on the [...nextauth].ts file or should call a function from

So I have something like this: ```ts CredentialsProvider({ name: "credentials", credentials: {...

Can someone help explain this code from the recent 'Dont migrate to tRPC' stream

On the stream at around the 2hr 07min mark Theo writes the following code: const sendTweetToDiscord = async ( tweet: NonNullable< inferAsyncReturnType<typeof getRecentTrashTweets>["data"]...

Custom admin CMS

Hey, say I have an app and I need a custom CMS I write to control its content, should I create a protected route in that app that leads to the CMS or should I go ct3app-turborepo and have 1 Next app and 1 Next admin app?