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

Why does that work? - Runtime Config with Nextjs

(unsure about the tag, so I am just going with both, feel free to correct me on it tho) Could some please explain why this working? I am working with runtime environment variables right now. As noted in the docs of nextjs it says that the page is required to be ssr'ed in order to use the publicRuntimeConfig (https://nextjs.org/docs/api-reference/next.config.js/runtime-configuration) ...

hey I'm planning to use this authentication method on my app.

1) browser sends creds 2) server sends an AES encrypted session, which has the username 3) browser stores it in the local storage 4) the session has a creation date so it can be expired after some time 5) the encrypted session sent with each request with the app not the browser...

What should i use t3-stack or express-trpc-nextjs for this project?

Hi guys, I have a question. I'm building a fullstack app and my first thought was to use t3-stack to do it, because it's so cool. But, the app needs scheduled tasks, wbrtc and very good interaction for realtime chat, so I can't decide whether to go for t3-stack or nextjs-express-trpc-prisma. Anyway, the real question, is there a way to deploy a nextjs project to render or railway and still gain the benefits of a CDN? Since Vercel does not work for my backend due to vercel timeout serverless...

Custom OAuth Popup Window Redirection

I'm building an oauth popup window like google, fb, github etc. I'm able to do the login, but not able to close the window popup once the login is successful. Example: 1. I open the oauth popup from my website : www.abc.com 2. The URL in the OAuth popup is www.random.com...

Optimistic updates not working tRPC useQuery

So I'm currently trying to implement an optimistic data update with tRPC. I'm following the docs. So far if I just do onSetteled it works fine and the data refetches after a second or two. Now I'm trying to implement the onMutate portion, and for some reason my queryClient.getQueryData() returns undefined, even though I'm passing it the same query that I pass invalidateQueries. Any insight on what I might be missing with the syntax?

Call Mutation again on Error?

Hey guys, if my token is expired, I need to refresh it and then call the API again. Whats the best way to do this in react query? I can't find a way to "re-call" the mutation on error. Should I be doing this in axios interceptors?

create mysql database automatically

Hello, i was wondering what is the best way of creating a mysql database automatically. Heard https://www.terraform.io/ may be a good option but it seems like its for larger projects and i don't really expect to have a large amount of data to begin with. Is there a better alternative or should i just go ahead and start learning Terraform

GitHub Action for Linting with Vercel

I’m trying to setup GitHub Actions to lint and prettify the code in my turborepo monorepo; it’s great and works really well to get everything set, but it’s throwing an error from Vercel; the lint-action user doesn’t have access to my Vercel account to create a preview deployment, and at the same time I don’t want linting to create a separate deployment. Given these things, is there a reason to use actions for this instead of something like lint-staged as a pre-commit hook?

Route guards for searchparams in nextjs

Is there any good way of parsing searchparams, asserting them to a schema and rewriting/redirecting the request to a url with corrected searchparams while maintaining full typesafety? I've written some code in the middleware, but I have zero typesafety regarding the search params in the pages and need to manually assign the types. Is there a good way to declare what kind of params a page takes?...

Intersection Observers

Can someone tell me what I'm doing wrong here? I'm trying to get this IntersectinoObserver to update other elements than the one actually being observed, when the heading is scrolled into view, i want the corresponding element in the TOC to update and change some styles on it, but i can only get the observed element to change. is this some perf thing that wont let you do this? Source: https://github.com/t3-oss/create-t3-app/blob/38fd589c3c43e21eef19ec177e78192884b79d9e/www/src/components/navigation/tableOfContents.astro Demo: https://share.cleanshot.com/xddfsF...

nested push-or-create-array in zustand and immer

Is there an easier way to accomplish this with zustand and immer, ie avoiding the conditional? this is inside a zustand create with immer middleware. ```TypeScript // StateType = { knownPaths: { [key: string]: string[] }; }; ...

SSG Helpers aren't helping.

As you can see in the image, I am not getting the proper html response after building and starting this project.

Is this context architecture too much?

Hello, I've just recently started using the Context API and I seriously couldn't find what's the most mainstream way of creating and using the context, but I found this architecture pretty understandable and I've been using it, but I feel like it's too much boilerplate? What do you guys think?

Handling Application Architecture

The long story short is, I currently have a fairly standard full stack app running. It's a mailing list and the frontend shows some Posting info as well (https://apptrack.tech is the website for reference). I'm trying to add a new application to accompany this. I really wanna use t3 stack for dev speed + nextauth is just super easy. My main issue is that my new app's data needs to have relations to the Postings in my original databse. I'm really lost on how to begin integrating these two and would love some help....

File Structure in T3 Stack

hello guys i wanted to know where do we put types and what the folder structure of it like for example do you put them in components/NavBar/types.d.ts or do you create a root folder /types and if you have other ways to structure types i would like to know your opinion on this

setInfiniteQueryData and getInfiniteQueryData compatibility

I want to setInfiniteQueryData to old data (before mutation). I have a following code: ``` const postMessage = trpc.useMutation("guestBook.postMessage", { onMutate: async (newMessage) => {...

Next-Auth CredentialsProvider not working as intended

Not sure how to use CredentialsProvider properly

Prisma 1-n relation create question

hello! I need to create a record and also many related exercises to this record, but the many records are also related to other models. Breakdown: A workout is connected to a program and user, and has (optional) many records....

How to switch from sqllite to PostgreSQL(railway.app)

I was working on an application using T3 stack and sqllite and everything was working perfectly but when I switched to PostgreSQL, it stopped working any idea whats wrong?