Hampterultimate
Hampterultimate
Explore posts from servers
TTCTheo's Typesafe Cult
Created by Hampterultimate on 3/27/2024 in #questions
NextAuth Session Typescript checks
My project uses : tRPC, NextJS page router, NextAuth (T3 stack), RecoilJS (state management) In my components there is this logic that I have to write everytime to satisfy typescript, whenever I am using useSession from NextAuth
const ChatDialogs = ({ chatId }: { chatId: string }) => {
const [allChatMessages, setAllChatMessages] =
useRecoilState(chatRoomMessages);
let chatMessages: TChatMessage[] = [];

const router = useRouter();
const { data: currentUserSession } = useSession(); //<---

if (!currentUserSession) { // <----
router.push("/");
return <></>;
}
...rest of the code
const ChatDialogs = ({ chatId }: { chatId: string }) => {
const [allChatMessages, setAllChatMessages] =
useRecoilState(chatRoomMessages);
let chatMessages: TChatMessage[] = [];

const router = useRouter();
const { data: currentUserSession } = useSession(); //<---

if (!currentUserSession) { // <----
router.push("/");
return <></>;
}
...rest of the code
I was wondering if there was something I could do so that I dont have to do this without forcing the type in. An idea I had was using a getServerSideProp on my home page and there I can check for user session and then passing the component session data where it will be of type Session only, and then passing it to the required prop. But then it will lead to prop drilling and I dont want that. Though I am using a state management library RecoilJS. I cant think of the best way. Can I get some recommendations of what you guys like to do in cases like this?
2 replies
TTCTheo's Typesafe Cult
Created by Hampterultimate on 3/25/2024 in #questions
Issues with queryKey
No description
5 replies
KPCKevin Powell - Community
Created by Hampterultimate on 1/15/2024 in #front-end
Responsive component with overflow scroll (Tailwind)
No description
6 replies
TTCTheo's Typesafe Cult
Created by Hampterultimate on 5/13/2023 in #questions
How do I use a tRPC procedure outside a react component
4 replies
TTCTheo's Typesafe Cult
Created by Hampterultimate on 4/6/2023 in #questions
NextAuth CredentialProvider with T3 default Auth Prisma models limitation question.
Actually I made a sign up page using CredentialProvider using Email ID and Password. My question is, 1.) create t3 app with NextAuth has built in tables named Accounts, Session and VerificationToken. Now due to me using CredentialProvider the rest of the tables are not being used because NextAuth is limiting that intentionally. More on that here -> https://next-auth.js.org/providers/credentials Now I want to know what functionalities I am missing, and do I even need those? Because my cookies are being created in the browser and useSession is also working fine. 2.) Also please tell me if I can delete the tables which are not being used in the prisma schema made by create t3 app.
30 replies