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

OAuth2+OIDC are very confusing

sorry for the very long-ass question, and thanks in advance. not sure where to ask this. (OAuth2 implementation) I just spent 6 hours watching videos and reading google-identity's docs on how to implement openIdConnect. and I'm still very confused. ...

Shadow db with prisma

I'm trying to use Prisma with Planetscale, but Planetscale only has 1 db in the free tier and I need 2. Any recommendations for setting up a shadow db in tandem with Planetscale?

Id in zod schema for frontend and backend?

Hi guys I am saving a "client" in my backend for that I have following basic schema, which is used in my frontend and backend ```ts const clientSchema = z .object({ id: z.string().nullish(),...

NextJS + tRPC API Logic Question

Are you guys putting your logic for your API routes in separate tRPC router and not making a file in the api directory? Or are you guys defining your API logic in files in the api directory and then also making a router file to define the typesafe inputs/outputs?

[next13] dynamic page or function

Hey yall I am having troubles understanding RSC and how next handles regen of pages. Basically I have a simple fetch / async call in my page. This page does NOT get regenerated upon navigation. Only when I hardload the page by hitting cmd+r. Docs say that all pages are static unless they are dynamic by having something in them that is only known at request time. For example a [id]/page.tsx is considered dynamic if it contains an async default function. a mypage/page.tsx is not considered dynamic, even if its exporting an async default function. So far the only way I have found to regen a page upon navigation to get the latest data is to either access cookies() or headers() from next/headers which is bonkers. ...

Unable to establish a connection to query-engine-node-api library on linux(Ubuntu)

I get this error when I try the
npx prisma db push
npx prisma db push
and even any prisma command.

how to reduce layout shift in astro

im currently in the process of rewriting my old personal site/blog in astro and i have almost finished it. but idk why the layout shift is so huge, please help deployed version: https://nexxel-dev-v2-6s310ftwp-nexxeln.vercel.app/...

No longer able to set background images in css with nextjs 13?

I cant locate the image inside the public folder using background-image property with css. I am importing the css file in _app.js and using latest version of next I need to use the background image instead of next/image because it is a sprite image from https://www.freakflagsprite.com/ with a row of flags....

Does anyone know why typescript type hints in vscode could be broken?

I'm in an electron app and for example when using await on promises, hovering over the variable shows it as a promise instead of the underlying type. Printing it out shows that it's not a promise?

react FC's tutorial?

hey does anyone know a good react tutorial that just uses hooks instead of components? trying to get my colleague to learn react, and was going to link him to the react docs, but the react docs all use class components 🤮 surely theres an updated docs in 2022 that teaches reach usign FCs...

Tailwind Widths and Heights

Can anyone tell me why tailwind seems to be missing a lot of heights / widths out of the box? Why do they stop at w-96? Why are there big gaps between the numbers? I know I can add other sizes to my config, but it seems like I might be doing something wrong. Similarly, why do max-w not have any numbers? what should i be using there instead?...

Whats better for Nextjs image src - import or path?

Is there a difference between, if so which one is better? import logo from "../logo.svg" <Image src={logo} /> and <Image src="/logo.svg"/>...

auth0 handleCallback vs handleLogin[returnTo]

Hi, I started playing with next.js + auth0. I am trying to redirect the user to a given address after login, but handleCallback (api/auth/callback) doesn't work. If I add returnTo to handleLogin (pic2), it redirects correctly. What is the callback for in this case? (docs does not help)

using next13 without app dir

Is there a way to do this? If so, how?

Notifications and live updates - are websockets the best way to do it?

I am adding notifications and live updates to my react app. I currently use react query for server state management on the frontend and mongo + mongo app services (realm) for the backend. Have setup an api that the client can subscribe to and thinking of following what TkDodo has mentioned in his blog post https://tkdodo.eu/blog/using-web-sockets-with-react-query. Is this the best way to do it or would you recommend something else?

How to throw a tRPC error if prisma query returns null

I tried the code in the photo but trpc query still returns null instead of raising an error.

How to mock useRef using playwright component testing ?

hello I'm writing test for a component with ref. I'd like to mock the ref element and change some properties but have no idea how to. Any suggestions? import { test, expect } from "@playwright/experimental-ct-react"; import { useState } from "react"; import { useRef } from "react"; import Main from "./index";...

How to have global state?

I want to set and read a state (the state will be an array of strings that is fetched when the user makes a search) from anywhere within the website(different routes). The information is temporary and can be deleted after the users session ended. reading the state needs to be really fast. I am kinda new to all of this. Is this a case for zustand?...

Spotify API calls using TRPC

Hi, I would like to make use the spotify API in my t3 app. The following repo shows how I would retrieve my token. https://github.com/spotify/web-api-auth-examples/blob/master/client_credentials/app.js Where would this be done in the stack? If there are docs highlighting this could you please point me to it? Thanks...