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

SSE - is it efficient to handle SSE this way?

I just learned about SSE and it seems each article is explaining SSE using an interval to write data to the stream. isn't that going to cost more cpu and memory? especially that each request to the server is going to create another async function that is constantly checking for data change. how can I trigger a stream-write whenever a database write has been made or something similar that is more precise? how do I associate the session id with the actual user? can I include a cookie in the request?...

for next-auth how to include a different model to a User Object

``` user { id: 'cla6t4y450000rpsvp6eijgdh', name: 'Batman', email: 'batman@gmail.com',...

TypeScript Generics

Hey. I need some help with TypeScript generics

How to handle Primsa DateType (JS Date) in getStaticProps | getServersideProps

I keep running into serialization issues when working with schemas that include a DateType since they are transformed into JS Date which is not JSON serializable. Atm I am transforming the Dates into numbers (miliseconds) to then pass to the component. But of course typescript is complaining. I wrote a generic that replaces Date types with number types inside another type but so far this does not work for nested types. There has to be a better way. Pls help....

is trpc + prisma right for my problem

Hello, let's say I want functionality add to favorites in my webapp. I have user session from next auth. Currently I am storing items inside User model in my database and then mutating and displaying items with help of trpc on frontend. But the problem is that all users see the same list of items. I have tried to filter it by user id but the issue is that now if one user adds Item to favorites, the other can not because its already there but filtered. Now I think that maybe I am overcomplicating...

Make Zod.string() handle empty string as undefined

Having a schema like
z.string().min(4)
z.string().min(4)
I want "" to throw Field X is required and "abc" to throw Field X must contain at least 4 characters....

How would you make requests to an Open API that follows traditional REST using t3 stack

Hello! I was wondering how I would go about fetching data from an open API that follows the traditional RESTful format using trpc. I would normally go about this with simple axios calls on the client, but I figured that might not be standard practice and wanted to get some insight on what would be the best way to make calls to an external api in the T3 stack.

Looking for something like upload.io but free for small usages

I'm just playing around with a side project and want a really simple API that allows me to upload files like upload.io. The problem is that upload.io is 8$/month even if 0 usage, and since this is an experimental side project it feels unjustified paying that much.

Solid vs React

The more I've learned about Solid JS and how it works specifically, the perf benefits from not needing to re render a ton of components every time any state changes and the signals. Especially with Solid Start coming out, in a year or two when solid start is way more stable, is there any good arguments supporting react over SolidJS, or Next/Remix over Solid Start? Other then maybe the fact that React at least for the foreseeable future has and will have more community support and is much more co...

Next Auth not working in production only

Hey 👋 My auth with Github and Google works great on my dev env, but after deploying my project to Vercel, Next Auth stop working correctly. When I use a provider like Github, I get the error Try signing in with a different account. and in the URL the error is signin?error=Callback. I created 2 apps for OAuth with Github, one for my dev env (redirecting to localhost) and one for the production (redirecting to my Vercel domain). I followed the Next Auth deployment, so I added a secret in my env vars and link it to the secret param in my config. I don't understand why I'm getting this error only on production and not in development 🧐...

[Tailwind&Prisma] How can you tie a tailwind color configuration to a prisma enum❓

Context: - You persist a user setting in your db, e.g. “primaryColor” - The CSS styles for this are applied via tailwindcss Problem:...

Module not found Can't resolve 'fs'

I am running into this error: ``` Module not found: Can't resolve 'fs'
1 | const fs = require("fs")...

List In UI Not Showing New Data Until Refreshed tRPC React-Query

II am showing a shopping list of items. I can create new items from web form but they don't show in the page until I refresh or click off the page and then click back on the webpage. Am I using react-quest / tRPC queries properly? https://stackoverflow.com/questions/74411386/list-in-ui-not-showing-new-data-until-refreshed-trpc-react-query...

Easy drop in payment solution? that works with t3 or nextjs

Easy drop in payment solution? that works with t3 or nextjs

Dashboards with Tailwind

Anyone know some good Dashboard starts with tailwind which then I can customize?

motion one doesn't allow for initial values?

motion one (https://motion.dev) seems very cool and all, but does it not have an API for initial values (similar to framer-motion)? its quite possible that I simply am making up an issue here, but surely if I want a fade in, the solution isn't to by default have the opacity of everything be 0 and then later change that in JS world? sorry if I'm just missing something and being stupid :)...

is Astro SPA a good idea?

Okay the plan is this (say we are making a dashboard or some other form of web apps, ignoring SEO stuff): - Create an astro project - have only a [...app].astro file in the routing, which contain an <App/> react component - handle everything else inside <App /> like a classic React SPA app It's probably not the type of things astro was built for, but what are the actual downsides of this I can expect versus other ways of making the same app (say t3 stack for e.g.)?...

What is everyone using for testing their T3 App?

I just wanted to hear some thoughts on testing philosophy as well as any implementation that people have.