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

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?

Stripe: Create new user on payment success.

Hi everyone, im making a system where only the users who make a purchase have an account, i was trying to use the invoice.paid event but it does not give me the checkout name/email. The checkout.session.completed gives me that information and the payment status, is it safe to assume that the payment will not be delayed and i can only listen to this event? Thanks

planetscale edge runtime

if i use planetscqle as a db and vercel edge function for the api , the db and the server will be in the same place using the bacit planetscale-js lib or do i have to use this one https://www.npmjs.com/package/@planetscale/edge ? i saw also this article https://planetscale.com/blog/introducing-the-planetscale-serverless-driver-for-javascript but i don't understand the concept of the location that could be in the same region as the server on the edge...

setData doesn't update state

I want to replace query invalidation with an update of the query cache to make my application react quicker. My understanding is that I use the setData method to update the query cache on success of the mutation. I've done so here: ``` const optionStateMut = api.option.updateOptionState.useMutation({ onSuccess: (data) => { client.form.getForm.setData({ formId: currentFormId }, (oldData) => { const newData = oldData;...

t3-turbo-clerk-drizzle

what about a stack for the edge? somebody has some example of this? it could be cool to use the zod types from the drizzle gen and implement them in the crud procedures on trpc...

prisma latency on the edge

Hi guys, I saw the latest video from theo about the latency of using an orm like prima vs other types without the crap of query binding with rust ecc that slow down the performance. BUT in this case he talked about an edge runtime, what about a static region for the server and also for the DB? The req time would also be that slow?

React query prefetch and fetch

Using react-query, what happens if you prefetch and while the prefetch is still happening, you click on a button (or whatever that triggers fetch) that fetches? Does the prefetch get cancelled, or does the fetch get cancelled? If both do not get cancelled, which data would be used? What if the prefetched data are stale and the fetched data come before the prefetched data?

Cors subdomains

Hi, I have hard time implementing CORS into t3stack, I have two subdomains:
app.page.com
recruiter.page.com
app.page.com
recruiter.page.com
...

Is there a way to call a trpc useQuery() multiple times?

I have a list of objects, and i would like to call the useQuery 1 time for every object in order to get some deta. Is there a good way to do this?...

Difference between where in Prisma

Hello, is there a difference between this beside how you write it? ```ts await prisma.user.count({ where: {...

is there any way to redirect to the default 404 page after your search query on the server component

```typescript export async function generateMetadata( pageProps: PageProps ): Promise<Metadata> {...

i18n in T3 stack/headless CMS

Will start today a new project with t3-stack. The client is an language school and we will offer the website in two languages. 1. Did somebody try to use i18n with t3-stack and 2. was wondering if Prisma/PlanetScale is a good fit for content driven websites in comparison to a headless CMS? ...

[Prisma DB] How to import from ssh tunnel

I made a request ticket on their site, but how would I import from a platform (kinsta) that requires ssh tunnel?