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

useEffect infinite loop

I am inserting values into my db using useEffect but it causes infinite loop

TRPC Invalid type error

Im trying to call my trpc endpoint from my chrome extension and im getting confused over the format i need to call it. What is the correct way to call a trpc endpoint when not in the next environment.

Zod one or more values from an array

Thanks in advance, my mind has gone blank and I just cannot think at this point. How can I say with zod I want to have at least one value of these array of possible values passed through. So basically a multi select picklist....

React-Native Error Cannot handle 'public.jpeg' media type

When I set allowsMultipleSelection true I get this error but not when setting it to false?! Why is that and how can I fix this?

BasePath and Locale broken

Adding basePath and redirect to it seems to break the app. Every time I enter my root page / it redirects me to /en/basepath (404) instead of /basePath. Whats wrong with this config? ```js { reactStrictMode: true,...

Auth on Mobile vs Web

In my mind, auth is mostly collecting username/password and sending it to the server, then the server can verify whether or not the username/password is correct. When the user visits again, I guess we need to re-authenticate with the JWT that's on the device. But none of these seem to mean that we need to do anything different for mobile vs web yet things like NextAuth don't support mobile yet, and most auth solutions have separate SDKs for mobile/web....

tRPC + external API

Hello. This might sound dumb but currently we need to expand the usability of our backend for a specific project. We will need to create a Typescript backend and I was thinking of using Next + tRPC. Question is, I will also need to interact with said backend on some cases but through tRPC endpoints in my app. Does doing this makes sense? And in that case, how can I make a tRPC procedure depend on a regular http call? Like for example formating some data and send it awaiting response from that POST call to our backend....

Apollo with nextjs 13 ?

Hi i'm a bit of a newbie, I want to build a blog app using next js 13 and the CMS strapi. I cant understand what is the best approch to make querys with this new server component, should I use the new fetch() function from nextjs server component or make querys with apollo on client side ?...

Use Prisma Enums in Runtime Validator

Can I use Prisma's generated enums in a zod runtime validator? I have in the @prisma/client this: ```ts export const Language: {...

NextAuth Discord Getting Guilds

I've been trying to do this for hours now, how do I fetch the users guilds via NextAuth ? I then want to store the guilds within the guilds within the token. Spoon Feeding would be amazing, I have depression because of this.

tRPC query syntax

Can someone please help a Noob here. I'm struggling to work out how to modify the create-T3-app code below for a findUnique or findFirst query where I will need both {ctx} and {input}. Apologies, I'm new to TypeScript ! import { z } from "zod"; import { router, publicProcedure } from "../trpc"; ...

EACCES permission denied

I am currently working on a messenger app which connects to aws amplify for the backend. Now I got these EACCES persission errors when I tried to make a pull request. I already tried to change the file owner with the chown command but it had unfortunately no effect. How can I fix this?

trpc error when deploying t3 app in vercel

I've been building an app for a while now and have recently been inspired it to convert it to t3 stack. Everything works locally, but when I deploy it to vercel I get this error every time i attempt to hit a trpc endpoint: ``` 2022-11-07T04:45:56.937Z b22c8823-6d79-4af1-8c81-ee002eda2b66 ERROR SyntaxError: Unexpected token ' in JSON at position 0 at JSON.parse (<anonymous>)...

Right time to use a monorepo versus a microfrontend solution? (ex Piral))

Having trouble distinguishing when each solution is appropriate to use. MFAs allow separate repos for each project so things are a bit cleaner in that way but ultimately if they're not going to be used independently, is a monorepo a better choice?

Tauri - the Electron Alternative - do I have to write any Rust code to use Tauri?

It seems that most of the APIs provided by Tauri are in TS/JS. Why can't one turn a website into a tauri app the same way one can turn a website into an Electron app with one click?...

Cancel current outgoing mutation when sending new one in create-t3-app?

I'm working on a project which uses optimistic UI updates when a user initiates a trpc mutation (so, e.g. as soon as they click a button to edit a piece of data, the corresponding data in the cache gets updated synchronously, and then overwritten by fresh server data once the request completes). Have tried to follow the patterns here, and it's been working pretty well: https://tanstack.com/query/v4/docs/guides/optimistic-updates The only issue I have with this approach is that, if the user is initiating multiple mutations at once this can lead to race conditions (e.g. there's one button which sets a value in a database to equal 1 and there's a different button which, set's that same value to be 2. If the user presses both buttons in quick succession, then whichever of the two requests resolves last will become the final result....

trpc response time

I have a situation where I need to record the response time of a request. If I wasn't using trpc, I would just record the start time, await the response and record the end time. Is there a way to do this, while using trpc?

TRPC type issue

I have a typing issue which I don't understand, I have this trpc create method ```ts create: t.procedure .input(createFileSchema) .mutation(async ({ input, ctx }) => {...

Nextjs detect previous route

Is there a way to detect if the user is going back to a previous page? Right now I am doing this which does not work always, seems like it does not work for nested routes not sure if there is a good solution ```ts export default function MainLayout({ children }: Props) { const router = useRouter()...

Authentication with Credentials with Create T3

Hi! Has anyone done a project using create t3 then used credentials with NextAuth? I found a tutorial online, but it seems to do things pretty differently from the way they would be done in the create t3 scaffolding. For reference this is the article that I was looking at, https://dev.to/franciscomendes10866/nextjs-authentication-with-next-auth-trpc-and-prisma-kgl. I tried to add/configure from this project to the create t3 scaffold, but I didn't have any success....