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

Metadata rarely updating when using <Link> to navigate

Hello all, I've run into this weird bug in NextJS 13.4 using the app router. For some reason when I use a <Link> to navigate to a page is refuses to use the correct title for that page. If I reload the page it shows the correct title. Now what has me really confused is that once in a while it does update for one page, but never changes after that. None of my pages are client side and I am using:...

Intercept request

Hi I wanna inject Authorization token in headers on every request. I'm very new to this stack and even to Javascript world also....

Create a global "reactive" variable

Hello everyone, I want to have a global variable which is available both on client side components as well as server side components. Is this possible? My variable stores translations. I want to avoid passing them down as props but I can't figure out a way to make them available in every component. It's important that the value gets initialized on the server, because I read the data by using the file system. Also I'd like to be able to change the variable and with it all components using the variable should get updated. ...

Why I am not able to use camelCase to use prisma models in trpc if I am using PascalCase name them

I have named the model SkuImages now I want to use it in the trpc procedure then it is showing errors.

t3 react clerk oath callback

Hey guys I cant understand this oath callback how do i put my scheme in app config and how do i make a oath callback link

[Solved] for the audio on uploadthing what filetypes exactly does it accept?

I don't want people uploading wavs just mp3s or if they do upload a wav convert it to mp3 without losing too much quality.

clean architecture

is it more good to use joi only without interface and only adopt interface on repo and controller layer...

Planet Scale foreign keys?

So The amount of read them doing in my planet scale database is kind of exploding (nothing not manageable yet) Is it possible to use foreign keys at all on the planet scale ? What are some workarounds...

Error: The Edge Function "index" size is 1.04 MB and your plan size limit is 1 MB

when I deploy my app I get this error now ``` Route (pages) Size First Load JS ┌ ℇ / 4.4 kB 164 kB ├ /_app 0 B 156 kB...

Using uploadthing with mongodb

Is it possible to upload it to uploadthing, then store the url in mongodb? I am using NextJS and NextAuth. I am trying to let users upload their own private images that no one but them can see, and I'm not sure how to do so with uploadthing.

How to handle getSession delay on client components with NextAuth?

Hey all. So with next auth, there seems to be a delay every time the getSession hook is used to make a request, which isn’t a big deal but can be a bit cumbersome when conditionally performing actions based on login state. Wondering what people are doing to get around this, I’m considering using server components as well as storing the session object in global state and revalidating whenever necessary. ...

[SOLVED] Next.js App Router with Express Custom Server

Hi Theo, I watched your YouTube video on App Router Review six months in, great video, thanks for posting. Quick question. I am looking for a project template / example that uses Next.js App Router (v.13.4.7) with a custom Express.js server backend, and can't seem to find one. I've tried ChatGPT, googling GitHub repos, etc., and can't find an example. Basically, I am trying to get a custom Express.js server to work with the Next.js App Router, but can't seem to get it to work in my project -...

Disable some eslint rules this in extend plugins

Hello ! I have this eslint config : ```ts...

Do I belong here?

Is this Discord server for members of a TypeScript course? Or is it for anyone interested in Typescript?

Protect routes? For the app itself, no user auth, pages router. Help, desperate.

Hi, I'm a noob and I've been winging it with Chat GPT My app is ready, Im using next js 13, now I came to the challenge of protecting the routes, specially because I have routes to create / delete / update....

TypeError: Cannot read properties of undefined (reading 'subscribe')

Hi, I have the following code and I keep getting the error "Cannot read properties of undefined (reading 'subscribe'), and I can't figure out how to fix it. This is the code: ``` export default function Page({ params }: { params: { subject: string } }) { const router = useRouter();...

tRPC query gets the type right on the way in and wrong on the way out?

This is a weird one. I have a public procedure (query) that takes a string as an input. Part of the procedure calls the Clerk API to get all users. I then need to extract just one property from each user and turn it toLowerCase() so that I can compare against the input string. I was getting a "can't read properties of undefined (reading .toLowerCase()) error, so I started logging stuff to the console and discovered that there's something weird going on with the types. On the way in, the query correctly logs out the type "string" for the property "artistName". But on the return (which is the second console.log at the bottom of the screenshot) it logs the type as undefined. Anyone know what's going on/what I'm doing wrong here?...

Why does the official Twitter website look so different on mobile?

So I recently completed theo's Twitter clone tutorial and wanted to go a bit further make the project look more like twitter.com. I noticed something. It seems like Twitter serves a different site to mobile user than on PC. How does that work? Can I set something like that with t3-stack? Also, do you think they use state hook for the " ... " Collapsing of names and @handles? Not needed but github link: https://github.com/Rasib0/chirp/...
Solution:
So I recently completed theo's Twitter clone tutorial and wanted to go a bit further make the project look more like twitter.com. I noticed something. It seems like Twitter serves a different site to mobile user than on PC. How does that work? Can I set something like that with t3-stack? Also, do you think they use state hook for the " ... " Collapsing of names and @handles? Not needed but github link: https://github.com/Rasib0/chirp/...

Request and update as the server comes along

So, I have a scenario in which I have a list of currencies, like ["USD", "EUR", "BRL"] etc, that has a dynamic size. My problem is that the API only allows for 5 calls per minute, so I need a 20s interval just to be safe. Now, requesting every 20s is easy, but I can't wrap my head around how to have a React Query set up so I read from this array of currencies, and return one by one so I can render it in real time on the client. And then restart the cycle. I've thought of many workarounds, but nothing that seems like a perfect solution. Does anyone have any idea on how I could do this?...

Can't resolve 'fs' but in an API route???

Any idea why this error is occuring? I thought all api routes are node compatible... ``` Module not found: Can't resolve 'fs' https://nextjs.org/docs/messages/module-not-found...