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

Make .useInfiniteQuery global

I have an infinite query and 2 different places where I want to have the data/fetch new data. These are my considerations: 1. I can't pass the data via a simple child component (lifting state up) because the other place is a page created via dynamic routes ([id].tsx) 2. I can't make the .useInfiniteQuery reside outside of a component, so I can't really share data via exporting 3. I tried using zustand/jotai to make the data and the fetchNextPage() global. This works as far as getting the first page of data and also running another db query for the second page, but fails when I want to get the data of the second page. (which means I really haven't found a way to get data from this point on)...

ISR in frameworks

I'm just curious, I have an application that is mostly static and doesn't need to be updated super often so I enjoy the ISR that next offers. That way I get the speed of static pages, but I can get new data when it is added. My question is, is there any other frameworks that use this feature? I didn't see anything about it mentioned in the astro docs for example (though I may have just missed it or it may be called something else there).

React Typescript SassError Undefined variable

I need some help on this please 🙏 I am new to using sass with react && typescript, so I declared a variable in a scss file but all I'm getting is an error that says Undefined variable

How to conditionally fetch data?

In my mind I want to do a mutation that returns data, but I guess that doesn't work. I have an edit button, and when the user clicks it and therefore goes into edit mode, I want to fetch some additional data from db....

TypeScript confusion

Can anyone explain why third-line errors but the fourth line works? ```ts type First<T> = T extends any[] ? T[0] : never; const myarr = [1, 2, 3]...

Not sure about router change?

By using next for few month , I have a question: What magic happens when router change? Instead of empty html and a main js,next give me a contentful html and that is why nextjs is good for seo.After hydration,the page become reactive. I was thinking that Nextjs's job is done....

What's the T3 way to load a font from google fonts?

above, I have it in _document.tsx right now ``` class MyDocument extends Document { render() {...

How to make a trpc function run automatically on start-up of server.

I'm working on a RSS reader like-app and am try to have function that runs every X minutes to refresh the feeds but can't seem to figure out how to go about this in trpc. Anyone have any suggestions?

Best way to validate multiple files via Zod & RHF

So I am adding validation to a form and I want to validate as much as possible on the frontend. Now I do believe some validation needs to be done by the backend, but I'll handle that after I've figured out what already has been validated by the frontend. The things I want to validate are the following: - The user has selected/uploaded at least 3 files for the form - The files are of a accepted file type...

does trpc support prisma transactions?

I'm trying to run a $transaction() on TRPC router according to T3 app configs, but I need some help figuring out where to start. Also, can an object be mapped to the Prisma update function? I'm updating the number of products sold in a receipt, but I need help thinking of a good way to do it. Thank you so much for your attention and participation.

How can I get history in NextJS? Or just Focus on item I redirected user from when he comes back

I need to focus on the item my user was redirected from to details page when he comes back. To do so I figured I need to have focus func in my general info page (/users/) and focus if someone is redirected to it from details page (/user/{id}). Do I need to get that id to focus on that item?

Getting no session from useSession() with NextAuth

I'm trying to implement a simple "username, password"-CredentialsProvider in my app. I'm using the standard prisma schema from create-t3-app, and just added a "password" prop to the User model. Im am using the authorize function in the authOptions of NextAuth ([...nextauth].ts) to check if a user with that username exists in my db, and also check if the password matches. If that's true, I create a new session like ```typescript...

gitlab - don't target master if target branch is deleted

In our current GitLab setup, we require each merge request to target a weekly business testing branch. However when these branches get deleted, any merge request that hasn't been merged yet will automatically change its target to master. This seems like the worst possible outcome as master is prod and we absolutely don't want to merge into prod without doing business testing first. Does anyone know if there is a way to change this behaviour in gitlab settings? I had a look around but couldn't find anything....

Recommendations for front-end error logging

Recently I got into the error logging rabbithole and im wondering if anyone has any good experiences with any front-end error logging services? For the backend I started using Axiom which seems to work great logging all the server activity on the Vercel side, but im looking at options now to also have logging for front-end errors. The ones that I have been considering and researching are Highlight.io, LogRocket and Sentry, but Im still open to any other suggestions....

Prisma client must use SSL or TLS error

Error querying the database: Server error: `ERROR HY000 (1105): unknown error: Code: UNAVAILABLE\nserver does not allow insecure connections, client must use SSL/TLS
Error querying the database: Server error: `ERROR HY000 (1105): unknown error: Code: UNAVAILABLE\nserver does not allow insecure connections, client must use SSL/TLS
It works if I use pscale connect and open a port on localhost, but it gives me that error when I use the
DATABASE_URL='mysql://***************:************@us-west.connect.psdb.cloud/example?ssl={"rejectUnauthorized":true}'
DATABASE_URL='mysql://***************:************@us-west.connect.psdb.cloud/example?ssl={"rejectUnauthorized":true}'
...

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?