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

Whats going on with these type errors? (Challenge, TSPlayground Included)

No mater how hard I try I can't seem to fix these Typescript errors. Tbh I'm not much of a typescript wizard and I've mostly been guessing at the types, any pointers in the right direction would be greatly appreciated. I seem to fix one error and three more pop up 🤦‍♂️ Playground (Test-cases & example included): https://tsplay.dev/Wzxn2N ...

Attempted to load @next/swc-darwin-x64

I just created a new nextjs project and the first time i run the dev server i am seeing some errors in the console but the app running and i dont know if this will affect my project, please how do i resolve this issue? ```js
next dev
...

What's a safe way to sign into your react native app using an existing web app/server?

As the title suggests, I'm starting to work on a React Native project that will be an extension (or side app) of another company's already-existing web application. They already have thousands of users in their DB and their own server of course. We have just started conversations with them about them opening up their APIs for us to extend our additions to their product on the app, however, their team is also small and it seems like they also don't have experience with sharing credentials across apps without fully opening up the API (there's a security concern, I suppose mainly around attacks). I have seen some patterns used on some apps where it seems like RN opens up the web app's login page on a webview and via a callback stores credentials. However I'm not sure if that's a) really possible, b) secure, c) the most efficient way. Mainly looking for guidance or resources as I work on this investigations. Happy to clarify as much as I can if anything is not clear....

Anyone been able to get Google Tag Manager working with Next 13 (App Dir)?

I have been following this tutorial: https://dev.to/valse/how-to-setup-google-tag-manager-in-a-next-13-app-router-website-248p but it's not working for me. It recognises GTM being installed but pageview tags aren't firing. Any advice?

Use NextAuth as a microservice

Hello guys, For a project I've decided to use a microservice architecture and I want to deploy a "nextauth API". I don't know if it's possible and I don't want to spend toomuch time in implementing it, if it's not possible. Thanks to those who will take time to anwser !...

useState is not working

can anyone tell me why in given below code is not working properly ```js const [localStorageTheme, setLocalStorageTheme] = useState(() => { const lTheme = localStorage.getItem("localStorageTheme"); if (lTheme) {...

What are the trendy server side stacks?

T3 is very fun to work with to make mostly frontend apps If we were to create such a project but for API running on node, what would be the tech stack? (context: I need to make a pretty big API for a side project (only API), and I want to have fun building it, but I don't want to use NestJS again)...

Best way to query data in NextJS App Dir.

Hi, since the new nextjs server actions are meant for mutating data, what would be a "proper" way of querying data in the app dir.

Nextjs (edge runtime) logging provider/library for prod

what's a nice logging solution for working with nextjs edge ? (CF pages/workers in paritcular) i haven't try logging in prod yet so this is very new to me. I've heard of sentry but i'm not sure of the other options. Most of the free(?) solutions i've found are libraries (pino and winston?) but they're for node. I can't use node tho because of edge....

Next.js for frontend only?

I brought this up in chat on a stream and wanted to have some further discussion about it. My company has separated frontend and backend teams, each using different stacks. This will not change - I've suggested it already and everything is too far along to migrate now. Due to this I'm having trouble determining what value Next might provide as solely a frontend framework. What value would it provide?...

How can I run a query only one time when the page loads?

I am trying to create a record of a session when the page loads so I can gather user metrics. Initially I thought that I could create a state variable (true | false) Then in a if statement I check if the state is false run my query then set the state to ture. ...
Solution:
I am trying to create a record of a session when the page loads so I can gather user metrics. Initially I thought that I could create a state variable (true | false) Then in a if statement I check if the state is false run my query then set the state to ture. ...

how to fix prisma query where 1=1

I have this query const user = await prisma.user.findFirst({ where: { id: session?.user.id } });, which seems to translate to
prisma:query SELECT `main`.`User`.`id`, `main`.`User`.`name`, `main`.`User`.`email`, `main`.`User`.`emailVerified`, `main`.`User`.`image` FROM `main`.`User` WHERE 1=1 LIMIT ? OFFSET ?
prisma:query SELECT `main`.`User`.`id`, `main`.`User`.`name`, `main`.`User`.`email`, `main`.`User`.`emailVerified`, `main`.`User`.`image` FROM `main`.`User` WHERE 1=1 LIMIT ? OFFSET ?
This guarantees that I return an entry even if id is undefined, which I don't want. How do i fix this?...

How to create components with React Aria?

I made the button component by example, but there is a Server Error. I don't know where is the problem, can help me? t3-app version:@7.13.2-beta.966c687 code link:https://stackblitz.com/~/github.com/birchrust/demo...

no-floating-promises error when using TRPC query.

I have this query using TRPC but am getting the following error. I feel like I should be resolving the prommis and don't get why this is happening. At a quick glance can anyone give some guidance?
Error: Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator. @typescript-eslint/no-floating-promises
Error: Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator. @typescript-eslint/no-floating-promises
```ts...

how to change nextauth PrismaAdapter's createUser function

is there a way to modify this or will I need to copy and paste the source and modify as needed?

How would you track API usage per user group on a series of edge functions

I have a need to track usage of some APIs (per group) for a set of APIs that will be deployed as edge functions with Vercel. Writing a UPDATE usage SET callcount += 1 WHERE id = $1 on every request seems like overkill, and using something like Vercel kv as a buffer would double the cost per API call. Typically if I was building a standard server component I would have it store a series of usage stats in a singleton that would flush out to the database over time, but that wont work with edge functions. Not sure what other approaches people might have or suggest. (the core database for the project is postgres with Vercel postgres)...

how to fix schema or query for prisma

I have this part of the schema: ``` model User { id String @id @default(cuid()) name String?...

One to one and one to many

Hello, I currently have ```prisma model Event { active_meeting_id String?...

VScode insiders code .

Hello guys yesterday I installed vscode insiders and after install, I wanted to use the code . in my terminal, bu it doesn't work. I googled around and found to use codi, but even that doesn't work, any suggestions?

How to server-render (SSR) a client component using Next.js app router?

Hey folks, This question might seem a little confusing. I'm learning about the app router and I'm wondering how I can achieve server-side rendering of the client components in the app router? I want the client component first render to be server-side, then the client component gets hydrated, then the subsequent rerenders will be client-side. This is needed for SEO....