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

Does cache control header work out of the box on self hosted NextJS APIs?

Does the
"Cache-Control": "s-maxage=123123123"
"Cache-Control": "s-maxage=123123123"
...

Looking for advice on how to fetch/load an onboarding banner

I'm using T3 inside a monorepo (turbo repo). For new users, I have a Get Started page that has a handful of checklist items. These checklist items are fetched from my database and ensure the user has finished the onboarding process. If there are still steps remaining, there is a banner at the top of the page alerting the user to finish their onboarding steps. My Question: Does anyone have any suggestions on how I can structure this so I'm not constantly running this query? Because right now, even if the user has completed all the steps, the app will still query and check to make sure all the items are complete. This in practice is good even after the user is finished onboarding because I want the banner to reappear if they delete their payment method or something. Can this be 'lazy queried' (not sure if that's a thing) or maybe run in middleware or something to where it would have minimal impact on the performance? Or maybe I'm overthinking this and I should just keep it as is? But in general I'm getting the feeling that I am running unnecessary queries and there is a better way to handle the logic here. ...

Stack for Discord Bot + Webinterface

Hello! I am new to the t3-app stack and was wondering how to properly implement a service like discord.js into t3. The Discord bot instance needs to pass live data to the web interface. Is there any way to accomplish this? How could the project structure look like?...

Stripe webhook error

Next 12: I've followed Next official guide for integrating stripe into my published site on vercel, and was able to make a purchase, but I fail using a webhook after a successful payment. On the Stripe dashboard, I see this error: "Webhook Error: No signatures found matching the expected signature for payload." My code for my api endpoint for that webhook is taken from the guide:...

`onSuccess` is typed correctly as `data: ReturnItem` for one mutation but as `data: any` for another

onSuccess is typed correctly as data: ReturnItem for one mutation but as data: any for another, any ideas why? I see no apparent reason.

Google Provider when deploying

I'm trying to deploy my project on vercel with a custom domain, but I'm getting an error that says something like: Google OAuth 2 authorization - Error: redirect_uri_mismatch. does anyone know how to fix this?...

A Complex Union Type

How to get this union type:
type MyType = "x:a" | "x:b" | "x:c" | "y:d" | "y:f" | "y:g";
type MyType = "x:a" | "x:b" | "x:c" | "y:d" | "y:f" | "y:g";
...

How do headless-ui expose context variable for child components?

Hey I'm trying to recreate a similar pattern to what is used in headless-ui Menu components. https://headlessui.com/react/menu ```jsx import { Menu } from '@headlessui/react' ...

Is there something like tailwind ui / headless ui for react native?

I'm a big fan of tailwindcss, but in order to speed up my process even more, I like to use something like tailwind ui with premade components, I can just copy + paste. Does something like that exist for react native, too?...

How to handle Prisma schema changes with PlanetScale

Feeling sooooo confused about what I thought should be a simple concept. I made a prisma schema change, just added a createdAt and updatedAt field to a model with the prisma @default(now()) and @updatedAt attributes. Then ran prisma db push, then opened a deploy request on PlanetScale. PlanetScale said the deploy would be safe. Then tried to deploy and got an error that updatedAt is not nullable and has no default value. How can I fix this? Why did PlanetScale say the deploy would be safe...

HELP HELP HELP HELPThis is the code it is nextjs with apollo graphql

this is a graphql directive If the cookie exists then I will send data otherwise I will delete the jwt ```ts function authDirectiveTransform(schema: GraphQLSchema, directiveName: string) {...

adding vercel vitals to CSP

next.config.mjs headers: async () => { return [ {...

.upsert when no way to track query/track unique identifier?

I have a (plan to) setup where a user can like multiple posts. This can be done once per day. ```model UserLikeStreaks { id String @id @default(cuid()) serverID String...

Handling third party API limits

How to handle external API limits? E.g. setting an API call in queue or something when the limit has been reached until e.g. 300 requests per minute are refreshed again. Rather this than keeping to send requests and getting API limit reached HTTP responses...

Clerk shared user state

I'm using the t3-turbo-and-clerk template and as I see, TRPC initializes the context with clerk's getAuth method so that the auth info can be access from the procedures. getAuth makes it possible to create a TRPC middleware so that the (whole) user returned from the db (relation with clerk's userId) can be accessed in the context. but what are the best practises to get the full user (from the db, not just from clerk) in the frontend? does clerk provide a simple way for that? if not, what is the best way to have the user also on the client side? I'm thinking about something just like the useUser hook from clerk but with my custom data...

Any good starter templates for electron?

It's kind of weird that their documentation has no template any where. Is there some template thats up to date that can get the intial setup for ts electron project?

Tailwind vscode extension not working

Does anyone else have had the same problem where the vscode extension is not doing anything? I tried botha default Next 13 app and the ct3a project. Both on windows and wsl2 it doesn't seem to wanna work...

Clerk? Centralised Auth

I need auth provider that can be used: - In web app (Next.JS 13) - In mobile app (Prob. React Native - Expo) - In custom BE facing external customers (Prob. Apollo GraphQl - https://github.dev/howtographql/typescript-apollo) I'm trying to find out if Clerk is good for this or not but I'm not sure what I'm looking for. Does someone have experience in working with this stack?...

How to add auth property to NextComponentType

Hey, I want to add auth flag to next components to check if page should be protected. I tried extending its interface but without any success. ``` declare module "next" { interface NextComponentType { auth: boolean;...

Is it okay to have CredentialsProvider as JWT and save Google/Discord users in database session?

I want to use both GoogleProvider and have an option to use traditional registered with Email/Password. How would you go around this?