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

Passing color prop isn't working with custom button

```ts import React from "react"; type ButtonProps = { disabled?: boolean; onClick?: React.MouseEventHandler<HTMLButtonElement>;...

Is changing fields on Session regularly good or bad practice?

In this example, I've got a new field on the session.user object called activeTeamId. This is then used to decide which team data to display for a user on a homepage. It also is used to create some trpc middleware that checks info about the user and their permissions on that team (whether they have admin privileges, etc). When a user switches teams in the app, I was planning to just update this session.user.activeTeamId field. Noticed that updates the session don't seem to propagate throughout the app super reliably (have not done a deep dive to examine why), so I was just wondering if there is some reason this is generally a bad pattern to use. Thanks!...

if i spread input will explicit defining it override the spread input?

Example ```js .input({ z.object({ email: z.string(),...

Strange Prisma error when trying to seed -- meta { column_name 'for' }

I'm trying to seed the following table. ``` model Contract { id String @id @default(cuid()) dueDay Int? @map("due_date") @db.TinyInt() ...

in a create-t3-turbo app can i have util folder under packages folder? so it can be share all round

Is this a good practice ? If yes do i need any further config to get it working this is my 1st time using create-t3-turbo app And basically its just a function to send email...

Error with env variables

Hi, i'm experimenting with the /env folder t3-stack provides, and I am running into an issue wherin my environment variables aren't correctly loading in. I've added them to .env and the serverSchema and i'm using them in the project as an import from env/server.mjs. Am I doing something wrong? Thanks in advance...

Help! I'm building small wiki app with Prisma and being stuck at paginate function.

It's mind boggling that Prisma doesn't have something so common that is count total record for all page in paging. I search on on their GitHub and found out that they have this issue opened for 1 year, and in the mean time user have to query to database 2 times, 1 for count all and 1 for paginated data. This makes me wonder that which one is better, "count 300 records then get 20 records for 1 page" or "get all 300 records with no paging."? Is there any better way to solve this? Should I wait fo...

I need to implement a schedule system, any suggestions?

Hi! I just need to let users select availability in a 7 day format. In addition, I need to display a simple calendar that shows their appointments after scheduling is done. Perhaps with rescheduling abilities. I haven't done anything with calendars before, any suggestions for building my own simple system and/or using an existing API?...

How does WASM fit into the T3 stack?

could someone help me understand where webASM fits into this stack? If I understand correctly, does NextJS internally do all the work of crunching the frontend into a WASM binary or is this something I need to do additional work to take advantage of? Thanks for any help I might have some holes in my understanding here....

Accidental state persistence across next dynamic routes?

Just noticed that /profile/[username].tsx persists useState() between different users in my app... My solution and the first stackoverflow answer I found is: ``` useEffect(() => { setState(resetState) // When the dynamic route change reset the state...

Storing Date and Time in UTC on PostgreSQL DB

How do you guys go about this? The docs are not making much sense to me. I am NOT using prisma.

vercel.json redirects not working in my Next.JS Project

Wondering why? It's just not working, giving me a 404 both on staging and when deployed to production. One is internal the other is an external redirect. ``` { "redirects": [...

TRPC cache (with vercel, but not working locally too)

Hello. I am using TRPC to make a site which integrates with a third party API. I need to add caching to some of my routes. ...

What is the best practice for unstable_getServerSession()?

What is the best practice for unstable_getServerSession()? Should I get the data using getServerSideProps in a layout and do a state drill? Or return the data with unstable_getServerSession() in getServerSideProps for each component it needs?

Is it safe to save user role in JWT token with NextAuth?

Hello, When using the JWT strategy, NextAuth puts the user role automatically in the token. Is this safe to do? If I google it, its a bit of a yes-no answer. If I look at Cal.com, they even put more information in it. I want to use the role only to check if authenticated user is allowed to visit a specific page. Of course, everytime a user does an action, it will be checked if the user is allowed via a middleware....

What's the correct place to put code that populates the db with default values?

I need to populate a table with some rows when the app deploys

How to modify useSession data type?

I am using credentials and providers then returning user, I was trying to put some user infos into session but session.user always returning ```{ user: { name: '1234', email: 'c@b.com', image: null,...

Next Auth JWT

Hello, I have 3 questions regarding NextAuth with JWT as session strategy: 1. When I return in the authorize function something like ```ts...

Session_ID in JWT

In my app I use JWT so I can verify that the token has not been tampered with, however the only information I store in it is the user's session_id. Nothing else, no user data, just the session id. Should I be just using a cookie or something similar? Thankyou!...

How do I get and save the access token from discord oauth create-t3-app

Hi, I have been searching around for a solution to this for 3 hours now, I am probably retarded. I am trying to get all the guilds from discord, but I need the access token for authorization using next auth in my t3-app. When adding the token to the session call back it errors out. I tried to use the jwt call back along with the session call back to see if thats what was needed with no luck. Link to solutions that I have tried:...