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

ESLint to force @types in dev-dependencies

We recently had an outage coz someone installed the @types/[package-name] in dependencies, but never installed the actual package itself. Particularly, they installed @types/imurmurhash in dependencies, but didnt install imurmurhash itself (and no one reviewing noticed it in the PR). Our no-extraneous-dependencies rule in ESLint didnt catch this coz the type declarations were present. Had the @types/ been installed in dev-dependencies, ESLint would have caught the missing dependency issue. Anyway to use to ESLint to check @types / packages are dev-dependencies and not dependencies ? I can raise an issue in ESLint, but was wondering if getting a solution might be faster here....

Updating existing T3 with Supabase Auth from Next Auth

Background: - Launched a T3 app with Next Auth. - Currently got 3000 users. - Launching an app version (expo), so migrating T3 app to T3-turbo. - Upgrading Next-Auth to Supabase Auth to work with React Native, want to keep existing users and ease migration....

tRPC + AppRouter without reactQuery

hi everyone how can i host trpc on next.js and use trpc on server components without using react query.

Mutate instantly returning success instead of isLoading

I have been working on this endpoint that uploads files do Google Drive. It can upload one or multiple files, so I iterate through the file list and await for each upload, so I don't spam Google's Api. My problem is that no matter what I do, the response is always instantaneous, but I don't see how this makes any sense....
Solution:
Welp turns out I had to do the obvious: return promise to resolve all :p

Next 13.4 problem with loading state after content is visible & hydration problem

Hey, I have a small app with Next 13.4 with Shadcn Ui šŸ˜ it's really really good. But I'm also using XState with a provider that I init on my layout.tsx file because I save and read the machine from a DB (don't ask why I'm just trying things). As you can see on the video, when I navigate, the content is first shown with the right data, AND AFTER, the loading state from loading.tsx is shown... ...

is there a way to change/refresh token when data in db changes such as role?

Hi, I had a project using NextAuth as my provider and the JWT strategy. When I use the database strategy, whenever I change the user’s role, they are automatically redirected to their own page. However, when I use the JWT strategy, I have to log out and log in again to get the newest token. Is there any way I can change the behavior so the token automatically refreshes when I change the role?

Refresh a single React Server Componetns

I have a dashboard where I want a certain piece of data to update every 10 seconds, what's the best way to do this with Server Components? The only approach I've found is to use startTransition and router.refresh() inside a useEffect with an interval.

Axios Singleton good or bad idea and how to implement?

Hey ppl, I'm asking myself a question. Is it a good idea to have a single instance of axios for an application? I'd like to take profit of interceptor and retry. But I'm not sure if it could go wrong if the instance can be corrupted or not? ...

Next-Auth in server rendered components aka appDir pages

how do we deal with next-auth in appDir? I am genuinely curious, as I am trying to migrate from pages to app but using next-auth you have to wrap the app in the SessionProvider, which isn't ideal to do in the layout component, making all its children client components. So is there any nice solution yet?

Any Clerk gurus in here? Following the Next.js 13 getting started guide renders blank screen

Following the getting started with nextjs guide for clerk renders a completely blank screen. I've followed it to a T, can't even set it up lmao. What am I doing wrong here? If I can't follow the getting started successfully then..... .env.local configuered with NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY src/app/page.tsx ```//app/page.tsx import { UserButton } from "@clerk/nextjs";...

Nested TRPC Calls

Hi, would anyone be able to assist please? Hope it's ok to post stack overflow link, just figured code would format better. I'm trying to call a TRPC method within another, but get invalid hook call. Essentially trying to modify returned products with s3 image url's being returning back to the component. https://stackoverflow.com/questions/76232392/nextjs-trpc-invalid-hook-call-nested
Solution:
useQuery and useMutation are hooks so you can only call them from within React components, and only unconditionally (ie no if statements etc before them)

Can I use tRPC with Next.Js App Router

I want to know if there's a way I can use tRPC with Next.Js app router. I mean, I don't want to use it in server components but inside client components to have the tRPC magic in them.

Suggestions for React Native offline-first DB with syncing

Hi all, basically I’m trying to get Firebase functionality without using Firebase. because of Their Typescript support is pretty bad and I would rather use something like Supabase on the backend. Things I’ve considered: - Realm: Not bad, would prefer to use a SQL backend - WatermelonDB: also flakey TS support and can’t get it to build with Expo...

Querying external api in trpc router not working

Hi guys! So I'm trying to query an api endpoint that I created through a separate node server inside my trpc router, I'm fetching it using axios but it does not work at the moment. I can't seem to figure out why.

infer from trpc calls

It appears trpc clients dont infer the return type, and I have to set it in useQuery like this.. const addressResult = api.registration.addressLookup.useQuery<{ a: string }>( { address: address }, { enabled: false }...

Using GithubAPI + NextAuth Github Provider to access a User's repo information.

I am building an app where will allow users to login with Github and view their Github accounts data ( Repos and issues ). A good example would be vercel or netlify, which accesses a user's public repos. I currently have Github Auth Configured... ```ts...

How can i use a random number without getting a hydration error?

Im trying to pass in a random number, but it's giving me a hydration error. How could i do something like this? ```js const DeveloperPage = ({ users, pages }: Props) => { return (...
Solution:
Inside a useEffect set a state to true, then just render nothing until it’s true

Uploadthing Issue

I'm working with UploadThing and am running into some issues: The terminal displays the message: [UT] SIMULATING FILE UPLOAD WEBHOOK CALLBACK http://localhost:3000/api/uploadthing?slug=imageUploader...

React Query For Asynchronous Data within Sanity Studio

I'm using the sanity studio to manage my Sanity CMS. I was able to configure a custom component that fetches data for a specific field in my sanity schema with this guide https://www.sanity.io/schemas/asynchronous-list-options-component-05f63a29. But it is using a normal fetch request which is not optimized. I thought of utilizing react-query for this but i was not able to figure out a way to wire react-query to the sanity studio client. Any input will be appreciated,...

Next Auth or Clerk

So I want to use Clerk, should I pull out Next Auth and replace it with Clerk, or do they work OK together?