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

Re fetch an enabled tRPC query.

Hi, im running into an issue where I want to refetch a query that lists all users when a new user is added, but it only refetches when the query is disabled. this is some code I have for it. ```javascript //Queries const createInvestor = trpc.admin.investors.createOne.useMutation();...

adding typescript to a vite setup in progress

I have this project started with vite and after two moths of working with it, I finally realised that I really need typescript. the problem is I can get vite to recognise typescript....

Deploying the t3-App on Vercel

I'm having a t3-app with the database hosted on planetscale and the app on vercel. Everything works well on the dev server but I cant make the connection to the db once I deploy it to vercel. I have mysql as my provider, and relationMode set to prisma. I have added the env variables on the .env file and on vercel dashboard. However once I deploy it to vercel I'm getting this error on the web console.

Adapt create t3 for mobile backend app?

Im building a fitness application right now with nest, prisma and graphql for my backend. Ive gotten highly interested in changing my code for this specific one. Im just wondering, i also want to adapt my endpoints to a mobile app in the future, ill think if i go native code or not. From what i see in the code, this is not possible to do with create t3, right ? Since there aren't declared endpoins ? I saw tcrp can be extended to have declarative rest endpoints, but would this still be a good solution if one was thinking about building a mobile version of the web app in the future? Would a mobile app be able to consume the server part of this mono repo ?...

Tech Stack Question

Hey all, recently got the opportunity to rebuild a local businesses website. Im trying to decide what to use for it. I'm thinking WP cause it'll be easy? However, I hate WP so I'd rather not. There's lots of content so I think using a Headless CMS would be great. Are there any ones you guys recommend?

Vercel deployment

I’m aware that vercel automatically deploys react components under pages. Looking at the folder structure T3 app created, will the APIs under server/trpc/router be deployed automatically? Or is there some additional configuration necessary?

How to update state after router.push()?

Currently, I have a router.push("/dashboard") on a page where I edit the session. Then in dashboard I have useSession() hook. If I manually go to /dashboard everything works because it is forced to update the state, but if I do router.push("/dashboard") it seems like it is just using the state that was there when the initial page was first loaded. Let me know if you know how to circumvent this!

query in next js 13 app directory

in next js 12 if we have a dynamic route and we want get the query we do for example this : getServerSideprops (context){ const { id } = context.query; } , so how can we get the same result with the new server side rendering functions ?...

TRPC max retries on endpoint

```ts export const authRouter = router({ getSession: publicProcedure.query(({ ctx }) => { // if (!ctx.session || !ctx.session.user?.accessToken) { if (true) {...

Any recommendations for a date library?

From my research it seems date-fns and dayjs are the most used ones. Does anyone have any experience with these or any other that you recommend? Eventually my app will have pretty robust scheduling functionality including scheduling online classes with 30 min. intervals. Thanks!...

What's a good service that helps scheduling cronjobs?

Looking into this right now. I need to trigger a few API calls once in a while. It's not a lot, so I'm thinking of getting a raspberry for this, but just curious what options are out there, if I want to regularly run a few functions?

NextJS body exceed limit when content sent in body is under limit.

I am sending a photo through TRPC that is then being uploaded to a server. Everything is working except sometimes it exceeds the body limit of nextjs api calls even tho I know the image is less than the limit. ```typescript const size = image.size / 1024; console.log(size);...

When to use Zod?

I'v seen the youtube hype for Zod now, but it still unclear to me when I should actually use Zod. Most of the examples I find online use Zod for something like API-data or user input data (like forms). But I use TS for so much more (well try to any way, still learning 😉). Should I just forget that TS exists and use Zod for everything I used to do in TS or should I use TS when not dealing with API-data or user input?...

Apple AirPod Style Animation on scroll

Hey, Kind of a noob question, but I wondered what the best way to implement something like this animation would be. Example: https://www.youtube.com/watch?v=hY1a94niwpY I did some research and found multiple ways, some use image sequences others mp4s. Just wondered how you guys would go on with this....

What am I suppose to do If user email exist on db that coming from provider? How to handle error?

I couldn't find any information about handling errors when user email (signed up with credentials) and provider email matches. How do I handle like "There is a user that you are providing from Discord" etc.

How to properly redirect to different page using trpc?

`export default function Post() { const { id } = useRouter().query; const postByIdQuery = trpc.post?.byId.useQuery({ userId: session?.user?.id, id: String(id),...

Closed modal keeps fetching

Alright this is a problem that I feel like I solved before, I have solved now, but my solution bothers me. Currently, I have a page that has 4 modals, out of those, 2 of them are supposed to fetch data right after they open, but here's the problem: they fetch all the time as long as I'm in that page. The obvious solution is to wrap the modal into a conditional render in the page that holds it, not allowing the modal to exist before isModalVisible == true....

How is option value string even after accepting a ``value={prop}`` of a number type?

Argument of type 'string' is not assignable to parameter of type 'SetStateAction<number>' Meanwhile I type setCurrentPage: (page: number) => void because the only thing i want it to accept must only be numbers ```<select name="num" onChange={(e) => setPerPage(e.target.value)}> {select.map((prop, index) =>{ return(...

will an empty input field override the current database value

if any of the input is empty will it override the current value in the database?

Prevent possibly undefined user with useQuery

I have a hook useUser that looks basically like this
return useQuery(// fetch user)
return useQuery(// fetch user)
Lets imagine that its used in a Layout so when the user is loading the whole app is just a loading spinner. Now I want to get the user inside a component nested in Layout...