Dylz
Dylz
TTCTheo's Typesafe Cult
Created by Dylz on 7/14/2023 in #questions
How to make extracting components in typescript less cumbersome?
So let's say for example I have a button styling that i'd like to use across most of my app. The recommended tailwind approach is to extract it to a component. However, doing this repeatedly can get quite cumbersome since I have to type every single prop. Is there anyway to infer or automatically create these prop types? I'm using webstorm and they have a extract to react component button, but it will just slap a :any on the props. Has anyone found a way to make the process of doing this more streamlined?
11 replies
TTCTheo's Typesafe Cult
Created by Dylz on 7/1/2023 in #questions
How to access form data from before a user is authenticated?
So basically, I have a user fill out a form that is then stored in global state. Once they complete the form, they are instructed to login with google to 'complete' their account. I'd like to link this form data to their account somehow but I'm struggling with finding a way to pass this data through the actual authentication process. Has anyone ran into something similar and how did they get around it? Do I need to store the form data in a cookie or some sort of persisted state, or is there a way to pass data to the middleware and handle it there?
7 replies
TTCTheo's Typesafe Cult
Created by Dylz on 6/30/2023 in #questions
How to redirect when user ~is~ authenticated
So there's lots of documentation about protecting routes, and there's also ways within the useSession hook to perform an action if the user isn't authenticated. But is there a way to redirect if they ~are~ authenticated? I'd like to avoid doing something like: const { data: sessionData, status } = useSession({ required: true }) const router = useRouter() if (status === 'authenticated') { void router.push('/quiz/results/success') } Because I get a react error about the component not finishing rendering. Is this the only way to do it or can i do something with next on the backend?
13 replies
TTCTheo's Typesafe Cult
Created by Dylz on 6/30/2023 in #questions
How to handle getSession delay on client components with NextAuth?
Hey all. So with next auth, there seems to be a delay every time the getSession hook is used to make a request, which isn’t a big deal but can be a bit cumbersome when conditionally performing actions based on login state. Wondering what people are doing to get around this, I’m considering using server components as well as storing the session object in global state and revalidating whenever necessary. Any other thoughts on how to handle this?
39 replies