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

Deceptive site ahead

Hi community, I have a Next.js app with NextAuth running on a VPS. Last night, I received a red screen indicating that Google had detected phishing. According to the Google Search Console, these are the URLs that are supposedly affected: https://mydomain/api/auth/signin/ https://mydomain/api/auth/signin/google I check the code on [...nextauth] and its normal. I have performed a clamscan of my repository on the VPS and all files are okay. How can I fix this issue?...

Benefits of RSC for dashboards-like apps

Hello everyone! I got a question regarding RSC. We have a single-page application that serves as a general management dashboard for our company. Would incorporating RSC offer any benefits for this kind of scenario? As I understand it, for internal tools like this one, the smaller js bundle size, which is RSC's primary feature, is not a concern. Furthermore, with RSC we probably wouldn't be able to leverage the significant benefits of caching and revalidation provided by tanstack-query....
Solution:
App dir Layouts are a huge win for dashboards though

is it bad to fetch data inside of the definition of a custom procedure?

here I created a custom procedure that had the user and username attributes attached to it from clerk, is this an anti pattern or something that could lead to low preformance?

Silly Newbie NextJS question

What causes the upper left tailwind svg (logo) to load late causing the header navbar to shift when switching from the Home to the About menu items? https://rtc-two.vercel.app/ I realize these pages are server rendered and the SVG is being loaded after the page is loaded. But I would assume that after first load, the SVG would be cached and load super fast....

Hosting

Hey! I am building an app in NextJS for a small company. It is a simple multipage webapp and I am looking for the cheapest places to host it. Vercel and Netlify which I have used for personal projects are $20/month, but the business won't want to pay that at the moment. Any recommendations for cheaper alternatives?

Error: P3014Prisma Migrate could not create the shadow database.

Error: P3014 Prisma Migrate could not create the shadow database. Please make sure the database user has permission to create databases. Read more about the shadow database (and workarounds) at https://pris.ly/d/migrate-shadow Original error: ...

Relation Mode Prisma Indexes

I'm getting this warning in my schema on the okr and parentTask lines any idea how to solve this?
With `relationMode = "prisma"`, no foreign keys are used, so relation fields will not benefit from the index usually created by the relational database under the hood. This can lead to poor performance when querying these fields. We recommend adding an index manually. Learn more at https://pris.ly/d/relation-mode-prisma-indexes"
With `relationMode = "prisma"`, no foreign keys are used, so relation fields will not benefit from the index usually created by the relational database under the hood. This can lead to poor performance when querying these fields. We recommend adding an index manually. Learn more at https://pris.ly/d/relation-mode-prisma-indexes"
...
Solution:
i figured it out'

which payment gateway should i pick if stripe is not available in my country?

Hey guys, hope u doing fine, i want to learn to set up payment gateways on websites, i wanted to set up stripe, but it is not available in my country, so i googled for alternatives and i found a bunch such as: 2CheckOut, paypal, braintree...ect, however, i really don't know which one to choose, so i wanted to ask here for orientations on which one should i pick, considering i use nextjs.

Jotai Bug?

Hey, anyone here that has worked with Jotai and is willing to lend me a quick hand about a bug I'm running into? been trying to debug this for 10h and I just don't understand. I have a simple set up that consists of three parts. 1.- API Calls to fetch an array of data...

Vitest folder structure

What is considered a good folder structure for tests? Should I have a single src/tests/ folder or have a /tests/ folder spreaded across subfolders of /src/

How to refetch data after Clerk login?

```ts <SignInButton> <button> Sign in </button>...
Solution:
Update your middleware matcher ```tsx export const config = { matcher: [...

Headless UI Stops Working when Adding addition elements to components

I have this component that I am trying to add a header to from tailwind UI, But when I add the header it no longer works. Here is the link to the repo I have working.tsx which is working vs index which is not working https://github.com/Tropic-OSS/Avias-Creations/blob/dev/src/pages/working.tsx...
Solution:
this div here that you have is staying on top of your nav bar, so you cant click on the nav items a way that can fix it is to have the <header> tag have "relative z-10" to move it on top of the other one, making the button clickable again and maybe removing the bg-white because it would look weird then...

CSS Styling

T3 recommends Tailwind CSS and I think I watch a video from Theo saying to stay away from higher level component level libraries (like DaisyUI).
I realize this is an opinion but since T3 is an opinionated "stack", is this what most people believe? Tailwind CSS? What about Tailwind UI and Headless UI?...

Good way to do many to many relationship Prisma

I have these schemas where I want to create a many to many relationship between the Xyz table to the subcategory as well as between the Kva table to the subcategory. This is a schema sketch of how I would want to do it but I get the error: Error validating: Embedded many-to-many relations are not supported on MySQL. Please use the syntax defined in https://pris.ly/d/relational-database-many-to-many Is there any way to do it without intermediate tables? Will add up to a lot of tables over time 🙂 model Subcategory {...

REST API Best Practice

As a general rule of thumb, should you always provide the same data for a resource back, if in one form it is an array, and the other is just that one resourse? For example, if I have courses. I could have a /course GET route that gets me back all of the courses for the user...

can't get query strings from context param

I was following the t3 tutorial and I got to he point where I should use dynamic routing in nextjs to get the post by id. Strange thing is, I can't get the params in pages/posts/[id].tsx,but I can with the [slug].tsx. THe context object is undefined. The routing is definitely correct, it's finding the page, but it doesn't pass the query string correctly. I've been on this for hours, pls help. here's my url to get to the page:http://localhost:3000/posts/clgo97nvn0001uty4q6s303cf ...

Local Edge Config "mock"?

i wanted to use Edge Config to make a very very very basic "feature flags" system. It seemed like the perfect fit, but how am I supposed to test it locally in development? so far, my entire stack, front to back, can run entirely locally. we use s3mock (by Adobe) to run a local "S3 bucket", and we have a local mysql database for development (no worries, our production database is on PlanetScale <3) i was really excited about Edge Config and i suggested a team member try it to implement a feature flag system (really dumb on/off toggles). unfortunately, it seemed impossible to have a local copy that each member of our team can run locally (for testing or development purposes)....

Why is this re-rendering infinitely

This block of code is causing infinite re rendering causing the app to crash with this error in console: Unique constraint failed on the constraint: PRIMARY...

Unable to invoke prisma mutation to planetscale dev branch.

Dev branch was created on planetscale and the env variables are set to dev branch values.
npx prisma db push
npx prisma db push
works fine and succeeds. Looking at planetscale the new tables/fields are created but when I go to try to invoke the prisma mutation I get the error:...
Solution:
(restarting the application again after
npx prisma db push
npx prisma db push
)

next13 app dir - multiple route handlers in one folder?

Is it possible to have multiple route handlers in the app/api dir in the same folder? It seems like it would get out of control pretty fast if you need to create a folder for each route… Compared to trpc for example where you could have multiple routes under a common path. You can do so with appDir route handlers but you’d have so many more folders and files… is this the only way or can you avoid all these folders for each route?...