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

Persist Theme Value in Nextjs from ContextAPI

Hello. I'm trying to persist theme data in a Nextjs application (v 13.1.1 pages) using ContextApi. Now, usually the theme state gets compiled from a ThemeContext and passed into the application. When the user toggles the theme, I save this value in local storage for when they come to the site again. This fails because Nextjs is first generated on the server and there's no local storage. What I tried...

Next 13 API responses just froze after build

This logic is supposed to return the current date when the end point is requested, it works fine on dev mode, but this endpoint response is frozen/cached after i run build, can someone clarify what is happening? I'm even doing the best i can on headers response and in client to turn this page like a getServerSideProps page

how long should install be?

we've been stuck here for a couple min.

P1001 Error with Prisma trying to reach database server

I’m following Theo’s T3 tutorial but when trying to do ‘npx prisma db push’ I get an error saying P1001: Can’t reach database server at ‘aws.connect.psdb.cloud’:3306 I can’t figure out if it’s an issue with planet scale or prisma and couldn’t find anything helpful online. Thanks in advance for any help...

Simple long polling with tRPC

I'm sending an email with a useMutation with MailJet. MailJet's API returns success, even when the email is queued, sending may still fail. They have another API to get the status of the email. I've created a backend function with Quirrel to keep hitting that API until i have a status that's not pending, and then put that status in my DB. Now I want to long-poll my db in the useMutation's onSuccess to check the email status. In order to do that, i create a function in the onSuccess that invalidate's the whole collection's data every second until i get the status. I'd much rather just check the ID of the item with like a Get API repeated and then invalidate everything when it changes... is there a way to do that with tRPC? Also, This sounds overly complex....

ThreeJS with Create T3 app

Hello, I have seen this repository that combines nextjs with react three fiber: https://github.com/pmndrs/react-three-next...

Role bases authentication with Github Provider using next auth

I want to implement a role based authentication like admin, author and reader using next auth and providers like github, so far I've found doing the same using credentials, is it possible with providers like github etc?

better supabase auth than with useEffect & getSession on each page?

apparently the way i was doing this was very noob, but not sure what the best alternative would be before i had a useEffect on each page in my webapp like this ```ts...

Session Auth using Redis and next-session

Hey everyone, This is more of a resource than a question, but I wanted to share an elegant approach to session auth within NextJS (in my opinion).
Personally, I've not had a great time using Next-Auth since most projects I'm involved with use credential-based auth. I find Next-Auth is a bit too opinionated for my liking and requires a certain database structure. That, and I'm not too fond of JWTs. After doing some research, I stumbled across next-session, which allows you to create a custom session store. The next-session docs are clear and concise and helped me create a custom session store with Redis (using ioredis)....

Prisma Unable To Query Indexed Fields

https://pastes.dev/Eir02TMjVU ^ my whole schema file I've generated and pushed multiple times, but I still can't query on the indexed fields.....

Global data fetching

Using non-app directory Next.js 13 (latest T3), how do you go about fetching data to be consumed globally? Since _app.tsx doesn't allow using getServerSideProps or getStaticProps ?

What would be a good practice for writing types for components that get passed a trpc query?

lets say a query looks like this: ```ts const item = await prisma.business.findFirst({ where: { id: input.id }, include: {...

Question about the use of useSession() callback

Why do all of the examples do the const {data:sessionData} for the callback when you can just write
const sessionData = useSession();
const sessionData = useSession();
? ``` const Home: NextPage = () => { const {data:sessionData} = useSession();...

tRPC query 'train'. what's the correct method to grab data from multiple sources?

I'm going to make an example as I'm either struggling to understand or am building my database wrong. A user has a profile page, to load this profile page we use the URL value. So I query tRPC when the username is entered into the URL /profile/Debaucus ...

TailwindCSS and CVA autocomplete

Hi guys, i'm using CVA with TailwindCSS for building complex state components, but a particular thing bothers me, is that there is not autocomplete of TailwindCSS clases in CVA. I'm new to Tailwind (i don't like it, but is fine to use it), so maybe some of you guys know a trick for this?

Session Auth without Next-Auth

Hi all, I’m primarily a backend dev with experience using Express/Fastify with session-based authentication using cookies and libraries like express-session.
I’m diving pretty deep into NextJS and the T3 stack, but one question I just haven’t been able to “crack” is how to do session auth using this stack. The vast majority of projects I’m in use credential-based auth, which I don’t find plays very nicely with Next-Auth which I know most Next devs use. I’ve tried it a number of times, but I really believe Next-Auth is a bit too opinionated for credentials (or at the very least requires a LOT of setup/boilerplate)....

[PRISMA] Value out of range for the type ERROR

I am attempting to create a headless wordpress setup with t3 1) I created a new wordpress instance and connected it to Planetscale 2) Tables are automatically generated (i believe during wordpress initialization) and pushed to Planetscale 3) I then connected t3 to the same Planetscale database and ran "npx prisma generate"...

Storing a snapshot of quizzes and responses in a PostgreSQL database

I am building an application that allows users to create quizzes and other users to solve them. The quizzes are stored in a PostgreSQL database. I would like to store a snapshot of the quiz, including questions and answers, when someone takes the quiz. This way, even if the candidate later edits or deletes the questions or answers, I can still accurately evaluate and display the responses based on the original quiz content. How can I best structure my tables to store both the quiz data and recruiter responses while maintaining the integrity of the data when the original questions or answers are modified or deleted? Current Table Structure:...

How would you structure this Component? A challenge to all advanced React users...

I'm having a bit of trouble structuring this component and I really don't know what to do about my data flow, so all help is appreciated 🙏 I'm creating an app to track what you have done on your job, like a diary. On the page /user/days/ you can add a new day. The main day component has 3 children each representing a section (general info, duration, timeline). The problem lies with the timeline component which has an array of activities and each of those activities is a separate component....