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

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....

TRPCClientError: Unexpected end of JSON input

Hello, I'm getting error 500 with message
Unexpected end of JSON input
Unexpected end of JSON input
for updating an entity, I only get this on prodution, on local env everything works fine, anyone has idea or had same problem?

Keep order of a list of items in prisma

I have an app that allows the user to reorder a list of items, with each item being a prisma model. To facilitate this, I have an index field that I can then order the items by when fetching. The problem with this approach is I have to update each item every time I delete or add an item. I'm wandering if: - there's a built-in way to do this in prisma? - is there a better way of doing this myself? ...

How to set envs as number in t3stack

I would like the envs to be parsed as numbers/booleans straight from env.mjs, how to approach that?

How to stop a form from submitting multiple times, even on slower network?

I have been developing an app recently, and during the testing I found some interesting bugs.. Short layout of the problem. It's a basic CRUD app, and while creating something I do that inside a form, and then I have a submit button which fires the onSubmit function. Inside the onSubmit function I do a mutation. And then in the mutation itself I redirect the user... E.g. ```...

Cannot access 'createTRPCRouter' before initialization

can anyone please help why this erorr is coming and how i can resolve it https://github.com/pradeep800/to-do-with-t3 Error ReferenceError: Cannot access 'createTRPCRouter' before initialization at Module.createTRPCRouter (webpack-internal:///(api)/./src/server/api/trpc.ts:6:65)...

Basic app architecture question for Auth/session state retrieval & storage

This is my first larger full-stack app so please bear with me 😄 I have a basic question regarding how to handle authentication state throughout the app and different components. So my understanding is, that to some extent you don't actually need global state management since you can rely on the hooks like useSession etc. to sync your frontend with whether a user is authenticated or not / get user data. But I have some parts of user data that is stored in another table, which I need to query with tRPC / Prisma separately (user profile data eg. full name, avatar pic url, etc). My idea was to create a global store using Zustand and set that data there once a session is created. From then on, retrieve it only from there, throughout the app and all components that need that data. Then have some invalidation logic to clear the store data when the sessions ends....

Weird default / route /en redirect behavior?

Can someone explain to me why navigating to localhost:3000 Is always redirecting me to localhost:3000/en/home?...

How to ignore peer dependencies?

Hi all, I'm using pnpm and turbo with more or less the T3 turbo github template. I've been really struggling with this error from the aws-sdk (Which I'm using to generate presigned urls for my users to upload images to s3): ```Import trace for requested module: @acme/nextjs:build: ../../node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/SignatureV4MultiRegion.js @acme/nextjs:build: ../../node_modules/@aws-sdk/client-s3/node_modules/@aws-sdk/signature-v4-multi-region/dist-cjs/index.js @acme/nextjs:build: ../../node_modules/@aws-sdk/client-s3/dist-cjs/runtimeConfig.shared.js...

Vite config with playwright-ct

on the project im working we are using absolute paths so.. ~/folder/to/path And im currently having this error: ```bash [vite]: Rollup failed to resolve import "~/shared/components" from "playwright/index.tsx"....

how come this returns undefined

The type of partPresignedUrl is:
{ url: string; partNumber: number; }[]
{ url: string; partNumber: number; }[]
Ie. its an array of objects....

Modifying 'Session' in next-auth

Code (I removed imports and comments as they are not required): ```ts declare module "next-auth" { interface Session { user: {...

Prevent public database access (AWS RDS with Vercel)

I currently have a database setup on AWS RDS that I connect to from my app hosted on Vercel. However from this article - https://vercel.com/guides/how-to-allowlist-deployment-ip-address Vercel suggests that I keep my security rules open for all connections (0.0.0.0). This seems like a great security risk even if my database is not that large yet. Do I have to decouple my backend and put it in an EC2 instance and abandon backend type safety for that reason alone?