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

Should I use next 13 or t3 stack for my current project (long term project)

if i do use t3, how difficult would it be to update to next 13 when it does become stable. also worried about how to use tRPC. i also def need the nested routing

React Query + Next 13 + Vercel?

Has anyone been able to deploy a site with RQ and Next 13 to Vercel? I am able to use RQ locally, both in dev and build, but when deploying to vercel, the page would return error 500. Not sure what could be the cause for me...

SWC compiler allows const variable re-assignment

I was trying out the SWC playground and I am getting no errors when I reassign a const variable. PS: when the function is not arrow function or when the code is out of that function, it throws the appropriate error....

Alternatives to redux for app state management

Hi! I know y'all don't like noobs much. But i could really use some help. Is there any better alternative to redux for app state management. Have to install 3 packages & still deal with weird lengthy syntax whenever i want to access my state.

Server side trpc call

Hi, In the attached picture, I am passing username from getserverside props down to my Profile page and I am doing a trpc call to query my db to check if the user exists. This works but I am currently displaying 'user not found' then displaying the user if they exist. I would like to carry out this call on the server so that I can avoid the lag and can display the user or 'user not found' instantly. Do you have any suggestions or tips on how I can carry this out?...

Generate Documentation based on comments TypeScript

Does anyone know a good library which generated documentation based on comments for my .ts and .tsx file / components? Tried jsdoc but that does not seems to work with typescript...

how bad of an idea is it to write to a pageViews column in the db on every pageload lmao?

how bad of an idea is it to write to a pageViews column in the db on every pageload lmao? I'd rather not pay for a 3rd party analytics tool while at a small size

Connecting entities in Prisma

I'm attempting to connect two entities in prisma which share a many-to-many relationship. I have defined the relationship in my prisma schema as an implicit many-to-many relation. It works fine if the connection does not already exist, and prisma is smart enough to ON CONFLICT DO NOTHING when it finds the connection already exists. However, it does not throw an error when this happens. As an example, my code for the route in question looks something like this: ```typescript // studentRouter...

Types error with Image component and NextAuth session

Hey, so I'm trying to display user image but typescript yells at me Type error: Type 'string | null | undefined' is not assignable to type 'string | StaticImport' Component looks like this: ```<Image
20 | src={session?.user?.image}
| ^...

Securirty issue next auth

Did anyone ever get anything like this? Google is reporting an issue on my site, I implemented auth with next auth spotify, but not sure why they're complaining about it

Importing country codes as an enum

What solutions do you recommend to deal with country field for a user profile? i was thinking about creating an enum file in the utils which i could use to import both on the frontend and the backend (prisma / postgres ) but the docs mention only hardcoding enums in the prisma.schema field (https://www.prisma.io/docs/concepts/components/prisma-schema/data-model#defining-enums) What is the best approach to avoid duplicate code? Any tips would be appreciated! Thanks!

Create-t3-app but Vue

This is m,ainly for the people that worked on creating create-t3-app going to develop an equivalent CLI for Nuxt/Vue + some other things i think are essential to an app it will be heavily inspired by create-t3-app but i also want to clone the repo, and selectively replace things therefor copying off most of the work. ...

Shadow Database Prisma & Planetscale

Hey! I've been following along with Theo's roundest pokemon app tutorial, and he makes a shadow db branch for prisma. My problem is that planetscale only allows 1 production and 1 dev branch for free users. Do I need the paid plan??

Conditionally change color of icon

Hey so I want to change a color of icon when clicked and it is inside state array I created. Currently I have something like this. <FontAwesomeIcon icon={faStar} key={coin.id} className={hover:text-yellow-500`}...

How to use fetched data as State?

I am getting data (a post) from trpc inside my component: ```ts [id].tsx const Post = ( props: InferGetServerSidePropsType<typeof getServerSideProps>...

next session is lost on refresh

Hi people, I have a problem that my session is lost on page refresh. I have getInitalProps in my _app.tsx and I can't manage to get session from there and pass it in SessionProvider I have tried getSession and ustable_getServerSession but both don't work....

Global Auth middleware tRPC problem

Im trying to build an admin dashboard app. I wanted more global approach for auth so rather than with protected/public/useSession approach which T3 is set up with Im trying to go with global middleware. So far so good it works but whenever I delete my session and tRPC request is made then middleware is calling redirect on tRPC api causing it crash as it responds with HTML document thus not making any redirect and making trpc erroring. refreshing works and I get redirected. Can I somehow overcome this and be able to also guard over trpc api calls or I would need to also disable middleware for /api/trpc and handle unauthorised on client? I would like to be able to handle it in middleware tho but can't find out how. ...

NativeWind vs twrnc for react native(+web) Tailwind solution?

Seems like NativeWind is a bit newer and has a nice Babel plugin that makes it feel like developing for web, but twrnc has been around a bit longer and has more interesting functionalities like ios: android:. Has anyone tried either?...

How to implement manual authentication without TTL entry

In MongoDB land, one way to create a user is creating a userToken when they sign up that automatically gets deleted by the database in expiresAt seconds if they don't confirm their account via email. What is the conventional way to accomplish this if there is no TTL functionality as it seems like Prisma doesn't support an expiresAt feature. I want to avoid a ton of userTokens accumulating in my DB if someone maliciously keeps signing up new accounts - besides rate limiting them and banning their ip etc. Just interested in db level cleaning solutions.. or alternatives to creating this userToken...