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

t3 stack - Prisma user name from user id

Hello, I have Prisma schema like this and I would like to get username for the post. Now I have userId but how I get username from that? I have username on my database so I should be able to move it to the session? Using client provider with t3 stack and on my session I have now id and email but how to save it to database(?) ```ts model User { id String @id @default(cuid())...

Is it possible to have a discord bot instance running in a t3 app?

I want to move my .NET & CRA discord bot dashboard app to t3 stack. The main reason I'm using my .NET backend for is to run a discord bot instance and some cron jobs. I'm not sure if this is something Next.js is capable of. Any insights?

Tanstack optimistic update for deleting a 'template'. I cant seem to figure out whats wrong..

Hi yall! At my work we have some big files called templates. They can go up to 10 mb (yes they are that big) and when deleting one it sucks for the UX. So I am implementing optimistic updates from tanstack query but I seem to be doing something wrong and my guess is because of my lack of knowledge.. Other info: - I have a TemplateProvider function that caches data under the cache key composed of an array of values ( ["templates", pageNumber, folderId || "all", search],) - I have a useRemoveTemplate() that tries to optimistically update the ui by following the tanstack docs (https://tanstack.com/query/v4/docs/guides/optimistic-updates)...

How do you execute a command which includes special characters from within bash script?

Hi, I'm trying to execute this command from within a bash script, but I cannot seem to figure it out. Copy-pasting it manually works. Any help would be appreciated. ```shell configure_gitlab_runner () { 'docker-compose exec gitlab-runner-container \...

VSCode Format on Save Help

New to TS and create-t3. Just started a t3-app and my .tsx files aren't auto formatting on save. Any idea if I need to modify anything in VSCode, as I have only worked with JS before this endeavor? The atuo-formatting works with the exact same file if it's a .js file btw

jwt vs cookies in next-auth

we recommend using sessions in t3-app but i don't know why. theo says to use sessions but what are the exact reasons one would pick one over the other while using next-auth?

Unable to send file to backend in trpc

Hi. Im trying to send files to backend using formik , trpc but not recieving those files object in my procedure . Does anyone know solution?

TRPC Testing Wrapper - Unit Testing components that contain a query (Not testing the query it self)

This is my wrapper ```js const TRPCWrapper = ({ children }: { children: ReactNode }) => { const [queryClient] = useState(() => new QueryClient());...

Nextjs Router typesafe?

Any way of getting Nextjs Router typesafe?

need help with a complex db query

im making a hackernews clone rn. on the home page i want to display the "trending posts": posts ordered by upvotes which were posted in the last 24 hours. but if there were no posts in the last 24 hours i wanna show the previous posts as well. and also if the user scrolls down enough i still want to show posts before 24 hours as well. how would a db query for this look like?

Next-Auth with my own supplied credentials (from a MySQL database)

Hello! I am creating an application that will be for internal employees. I would like to use Next-Auth for authentication. However for now I have only tried out the standard providers like (Discord, GitHub, Google etc..) For this project I have to use my own credentials. Supplied from a database that I host. I have tried looking at the web for some examples on how to do this, but im not able to find any good examples. In the docs you get a lot of the code for you, but not the logic for verifying the user/password and getting it from the database. Does anyone have a good example/tutorial for this? That would work in a real life application. I have heard bcrypt is good for hashing? 🙂...

How why to replace min-width in my CSS

I've been getting into replacing all the styles in my app with tailwind recently. I've mostly found this to be rewarding, but I'm confused about the lack of options available for min-w-*. I asked a question about it here before and I was told that using min-width with specific pixel values was generally not a good idea. That being said, I'm having a hard time getting the desired behavior I need without it. For instance I have the following div: ```html <div className="border-1 mt-3 flex min-w-[300px] flex-col gap-4 border-solid border-divider p-4 shadow-xl"> ......

Next Auth Discord Callback error...

I really can't see what i/m doing wrong here. I've added `https://hciav.vercel.app/ to my NEXTAUTH_URL and NEXTAUTH_SECRET as a hashed string to my vercel environment variables. but i'm having no luck with this. the localhost:3000 implementation works fine...

Is there an 'easy' way to expose tRPC function as an external REST API?

I'm just curious if there is a way to expose certain tRPC functions as a REST API. One of the reasons I'm asking this is, imagine you have built an application and now you might wanna sell (or expose it, don't have to sell it) your backend to other consumers.

How to deal with env variable being string | undefined when clientId is expecting only string?

I'm trying to think of a solution to this... any ideas? So far I'm just doing typeof, and if it is not string then error.

invalid environment variables

Hey all. I'm using create t3 app but having some difficulties with custom environment variables. The .env type safe code is messing me up. ...

Link Error NextJS 13

I have removed all the a tags inside of the link tags and have run the auto codemod provided by next. I am still getting this error. Can anyone help me out? Thanks...

Help me type this function

I have a function that takes in an input function and returns another function who's input is the same type as the function passed into it. ```ts function Foo<T>(callback: (input?: T) => void){ return async function(input?: T) => {...

Reusable components folder location?

Hey guys, where do we put reusable components in Nextjs?