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

CT3A redirect to deeper route

So I have a /dashboard/[setting].tsx page which I use to load the dashboard settings, blah blah you get the idea. How do I redirect /dashboard to /dashboard/${settingId} (I have settingId already and it is safe to assume it will be a valid URL)...

SessionProvider Context Noob Question

If we use getServerSideProps, I can understand where pageProps.session is coming from. However, if we use useSession (getting session on client side), does it somehow attach it to the context still once its fetched? Since it does not come in as a page prop in this case I am a little confused. Thanks!!...

create-t3-app not working with yarn 3?

Is anyone else facing issues using create-t3-app with yarn? There's an open issue on GH that's tagged as "won't fix" which seems odd to me (https://github.com/t3-oss/create-t3-app/issues/454). I'm wondering if this is a problem in general or in specific cases and if there's a known workaround (other than not using yarn). It worked fine last time I scaffolded a t3 app a month or so ago, but that wasn't using trpc and nextAuth (don't lynch me, was just a toy project using GraphQL for a tool for work)....

fix create-t3-app (and trpc) dangerous default?

By default, trpc (https://github.com/trpc/trpc/discussions/2071) and create-t3-app send server errors to clients ``` const t = initTRPC.context<Context>().create({ transformer: superjson,...

planet scale vs digital ocean?

Planet scale seems overpriced … why is it a good choice over other services?

Signin in turborepo t3

I'm running a t3 turborepo that has 2 apps, 1 admin (CMS) and the client next app. The login is done using credentials, how can I do so that when you login in the admin app you get redirected to localhost:3001/ (admin), and when you login in the client app you get redirected to localhost:3000/? Currently when I login in admin I get redirected to the client /...

Zod - `require_error` in string not working when also using `min`

Does someone know how I can show the required_error in Zod?
z.string({ require_error: "Name is required"}).min(2, { message: "Name must be at least 2 characters"});
z.string({ require_error: "Name is required"}).min(2, { message: "Name must be at least 2 characters"});
when I parse this, it only shows that I need at least 2 characters, even if the string is empty...

TailwindCSS Plugin - Allow arbitrary values

Hey 👋 I'm creating a TailwindCSS plugin, and I'd like to allow for arbitrary values. I couldn't find a setting where I can enable that. Any ideas?...

Little Breakpoint Utility Component Help

Hi guys, i'm trying to write a little breakpoint utility component... i must be doing something really silly wrong... if i uncomment the "Size" line, it works, but the container is still not bg-red-500, and the word Size never shows up anywhere.....

Cannot get the document of an iframe

so I want to get the document of an iframe in order to change the .playbackRate of the first video element inside it. But neither iframe.contentWindow.document nor iframe.contentDocument return me the document. In the second screenshot you can see what iframe.ContentWindow returns....

Zod inferred union type does not work properly; 'hackerProfile' does not exist on type...

Typescript is telling me that hackerProfile, partnerProfile, and mentorProfile don't exist on my UpdateUserInput, which I inferred from Zod. Even though I can see hackerProfile, partnerProfile, and mentorProfile in the type when I hoer my cursor over it in VS code. It doesn't seem to have a problem with userUpdate. What's going on here?...

vercel lambda warm up

Does Vercel's serverless lambda functions have warm up issues? If so, is it as severe as AWS lambda?

is there an image lazy loading library for astro?

I found this cool library called Blurr-Hash with helps with lazy loading images in a really cool and efficient way. but the thing is I also want to use this component from @astro/image called Picture where I can specify multiple versions/sizes of images. and I don't know how to combine both, then I thought there must be some library for this that is specific to astro. unfortunately I found non....

How to infer the ref type of a component?

Let's say you have a component that wraps an input: ``` const Input = React.forwardRef<HTMLInputElement, React.ComponentPropsWithoutRef<"input">>((props, ref) => { return <input ref={ref} type="text" />;...

Handling prisma errors

Hey, quick question. Let's suppose that in my db I have model User with few unique fields: name, surname, email Should I validate manually that those fields are unique and throw an error if not or should I just let prisma do it? I guess that the 2nd solution is better. How do I map prisma errors to show more human friendly messages than this: ```ts { "statusCode": 500,...

Next.js middleware with NextAuth server session?

What is the best way to write a Next.js middleware (middleware.ts) that redirects to /login if the user is not logged in? I'm using the t3 stack with db sessions

Casl.js with create-t3-app

someone knows how can i setup casl.js for authorization? it is possible to use @casl/react with @casl/prisma ? i googled these question but i found nothing

Typing component based on props

Hi all, I'm trying to type a Link component based on it's props. If url is passed as a prop, I want the type of the component to be an HTMLAnchor element, if I pass in an onClick I want it to be an HTMLButton etc. I have the following but it doesn't seem to work. It lets me pass in both an onClick and an href, which shouldn't be possible as href doesn't exist on HTMLButton...

Audio Recording and Playback.

whats the best way to do this in react? all the libraries i find are old, i have a written a hook that records audio and returns a blob just want to know if there is a better way to do this.....

NextAuth CredentialsProvider + database strategy

It looks like NextAuth does not want you to use the credentials method in combination with a database. Even when providing a database adapter, NextAuth does not store sessions in the database. Is it advisable to just use JWT instead, or switch to another library?