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

For whom and when does it make sense to learn a Framework like React.

I am relatively new to webdev and currently just use Flask for my backend to render my HTML files and then just use scss and Typescript on client side. My question is when does it make sense to start learning React and why would you even need it in the first place except for saving time by having reusable components?

Clerk | Next 13: 401, unauthorized when trying to hit Next backend.

I have set up the following middleware: ```ts import { authMiddleware } from "@clerk/nextjs"; export default authMiddleware({ publicRoutes: ["/", "/sign-in"]...

Creating (guest)checkout sessions with TRPC/Stripe/Zustand.

Hi! Just asking to see if this is a correct approach I am managing carts using Zustand since it is just a simple side feature of the website where they sell some merchandising. Since customers can order as a guest, I am creating a public createCheckout link function in my stripeRouter. If users have a account I will link the order to the user. ```...

Best sources for UI inspiration?

I know there are some websites where devs can show off their UI and you can gather inspiration, but I forget their names, so if you know something like that please drop it here!

Cheapest Hosting Service

Hey folks, it's my first time doing freelancing, so i'm building a web app for the client and after that there is still all the maintenance. This is for their internal use, so I'm wondering if there is any cheap hosting services?
Solution:
For Next.js, I would strongly recommend Vercel

Fetching Data on the Server

I was checking out the create-t3-app docs and saw that getServerSide props was discouraged. Then what would be the better way of data that should be available on page load. For example in my current project I have a nav bar that populates the products element with data fetched from the server. When activity on page is low response time can be around 2 seconds from supabase. Instead of fetching this on client side and waiting I'd rather have the page load for a bit longer and serve all as static...
Solution:
Since you're using tRPC, you could very well look into SSG and prefetching trpc queries

VSCode debugger help

So I need some help with setting up a debugger. I have a dockercompose which runs like 7 docker containers. for the mian container which runs the server.ts the debugger works. If I use the same approac to create another debugger for another service which is like src/exports/exports.ts and make a debugger and launch.json for it, it can't connect I get the error no debugger found or something like that. When I try to curl ocalhost:<port> I get empty response is it a problem because the export.ts is not a server but just a Script that runs on the container? is there something I can do to make the debugger work? ...
Solution:
Solution - On all NPM scripts add: --inspect=0.0.0.0:9229

Multi-page wizard

Thoughts on this approach? I am trying to come up with an easy maintainable but efficient way to configure a multi-page wizard. I've used useWizard before, but that ended up in a really messy architecture where everything had to be stored in state. Hence, I am trying to create a multi-page wizard where I can use the App Router for some server side fetching and loading.tsx...

Should you validate the output of DB query?

I know user input should always be validated before being stored in a DB, but what about query results? should they also be validated with zod or in a tRPC output function? interested to know if anyone has any thoughts on this....
Solution:
I personally wouldn't bother with it unless I'm transforming it further but if you want to do it you can either manually schema.parse in the body or rely on the .output property of the procedure to ensure its what you want

Adding ISODate() for comparing dates in prisma with aggregateRaw on mongoDB

Hey guys hope you're doing all great!, I've been trying to compare dates using aggregations in mongoDB with prisma.aggregateRaw() function, in mongo compass tested this query and works well ``` { $match:...

Lambdas and Edge functions in same tRPC Project?

How do you create a trpc app that uses both Lambdas and Edge functions (NextJS specifically)? Do you need to create two separate routers? Been struggling to find the right way to do this.

Deployed app not showing time in date

I`m using t3 stack with Supabase, on local machine I can query full date with time stamp without any problems, but when I deploy my app to Vercel, it shows time as 00:00 when I query something.... Someone knows what's up with that?

t3 stack with a node/typescript/module example?

Trying add a node service that is typed but when i import import { prisma } from "@acme/db"; say that package can't import env.mjs. anyone have an example of this working?

I have been stuck on this Type error: Cannot find name 'TRPCError'. Did you mean 'RTCError'?

https://i.imgur.com/19Sz2Ya.png https://i.imgur.com/fTNtGND.png I am following the 3 hour long chirp project and I've been stuck with this error for over 24 hours. I just came across T3 stack recently and I am trying to learn it. Please let me know if you need more context...

TRPC vanilla queries (T3 stack)

Does anyone know how to access trpc vanilla queries (not hooks)? ```ts async function handler() { const response = await api.example.hello.useQuery() // more like a fetch then a react hook....

NextAuth errors.ts issue

Has anyone else ran into this typescript issue with NextAuth's errors.ts file when running the build script? It's been brought up in NextAuth's github discussions, but no response from their team. I'm using the latest t3-app. Failed to compile....
Solution:
If this helps anyone later, I figured out this problem came from my IDE incorrectly importing type Session from "next-auth/src" instead of "next-auth".

Suggestions for a minimalist neovim settings?

I am starting to use neovim and I would like some suggestions about the basic plugins and settings I should have (let's say to code on a T3 stack). I just want what I will be using and nothing more: as simple as possible but with what brings the most value for productivity and DX. Thanks! 😁

Handling Long-Running Server Functions in Next.js: Seeking Alternatives to Vercel Time Limits

Hey everyone! I'm working on a Next.js project where I need to sync and handle all new emails from an email server to a database. This process can take a couple of minutes, but I've noticed that Vercel has time limits of 10 seconds on the free hobby plan and 1 minute on the pro plan. Unfortunately, these limits are too short for my use case. Can you share any insights or alternatives you've used to handle long-running server functions in Next.js? Thanks in advance for your help!

Paypal webhooks

I've successfully set up paypal subscriptions inside a nextJS app whenever i subscribe using the paypal buttons, it works just fine, but the only event that's fired is BILLING.SUBSCRIPTION.ACTIVATED if i have my subscriptions be billed monthly, should i wait one month for the PAYMENT.SALE.COMPLETED event? i was expecting both BILLING.SUBSCRIPTION.ACTIVATED and PAYMENT.SALE.COMPLETED would fire when a user first subscribes, then PAYMENT.SALE.COMPLETED for the next payments...