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

Nextjs Middleware to redirect

Hi I want to redirect this route / to /dashboard for that I created a middleware.ts inside src ```ts import { NextResponse } from 'next/server' import type { NextRequest } from 'next/server'...

Host pdf files locally or online

Hi! I'm building an application where a user can upload a pdf. Is there any way i can host these files in nextjs(using ct3a with mysql) similar to how we can do that in express Also is there any free tier service which allows to host static files online which i can access using nodejs . ...

Jest on dynamic routing

Doing unit tests on Nextjs page with route of id, how do I pass in the query of id to not get the Error: Uncaught [TypeError: Cannot read property 'query' of null] error? ```js import Scholarship from '../pages/scholarship/[id]' describe('Single scholarship page', () => {...

Why is noUncheckedIndexedAccess enabled by default?

I started a project using create-t3-app and I was getting all these type checker errors throughout my code, which forced me to manually reassert types all over the place. Setting "noUncheckedIndexedAccess": false in tsconfig.json solved the problem with my type checker but I'm left wondering why this was enabled by default in the first place. Manually reassert types all over the place seems to run contrary to this discussion: https://www.youtube.com/watch?v=RmGHnYUqQ4k

T3 Docs - code explanation

```js import { DefaultSession } from "next-auth"; declare module "next-auth" { interface Session {...

Astro or NextJS for single page website with contact form?

Hello everyone, I'm currently remaking a single page website with contact form and wanted to ask for advice. I thought is would a be an overkill to make it in NextJS so I thought I would go with Astro, is it possible to use nodemailer with Astro if i want to host my website on cpanel? Thank you in advance

converting TailwindUI syntax documentation to a page in my app.

Hey I’m just struggling to convert the Syntax docs template from TailwindUI into a page in my application.

How to use tailwindui app shells with t3

I am not sure on how i would go implementing a tailwind ui application shell. Usually i would just add my header and footer components between <Component {...pageProps}> but i keep getting errors related to the way useState is different between the one rendered on the sv and the client one. Tried looking at nextjs docs for a way to add the layout but cant figure out what type i should give my component. If any of you have a repo that implements it or anything i could use i would truly be grateful thanks...

Large POST request on ESP32 over SIM

Hey, bit of a pot shot putting it in here but anyways My Microcontroller is an esp32-cam, and I am trying to currently write a function to send a POST request containing form data to my server. I am using TinyGSM with a SIM7600 module....

Next 13 AppDir + middleware

I tried to create an app with Next 13 and play with the new app dir (beta), but I couldn't make middleware to work. I had no pages dir, all pages were rendered correctly but it seems like middleware was not firing. Is this not yet supported ? I couldn't find anything in the stable or beta docs of Next...

How to trigger NextJS Image fetch again if not loaded in 3 seconds

Hi, I'm fetching images from an unreliable gateway that sometimes require multiple tries (same URL) to load the image. Is there a way using Next Image/Future Image to trigger a fetch from the same src link again if it is still loading after 3 seconds or if the load has failed? Thanks for your help!...

Im converting my old code to Typescript, I need help with a functions.

Howdy, im just converting some of my old code to Typescript from JS and I am struggling with a few functions. Answers would be amazing.

Getting user IP in trpc without req object?

I used to get the users IP like so, just giving the package the req object: ``` const requestIp = require('request-ip'); const ip = requestIp.getClientIp(req);...

Set value based on current

Is there a shortcut for setting a value based on it's current value in Prisma, I have a field that's initially null that I would like to update in a webhook, but if it's already set i don't want to update it. Can i do this in a single query or do I have to first get the field and then update based on the response of the firrst query?

can i export data from reactQuery?

Please i need some help here. 🙏 I fetched data[] from an API using reactQuery but the problem I'm facing here is that i need to export all the properties decontructed from reactQuery such as the data[], isLoading, error so that i can be able to use it in another component, is this possible? I name the file userData.tsx ```export const UserData = () => { const { data, isLoading, error } = useQuery<User[], ErrorConstructor>("query-users", async () =>{...

Filter Query with multiple parameters

What is the recommend approach when creating a query that needs to filter based on some conditions which may or may not exist (if the user doesn't specify them we should ignore the filter rule) while using prisma? Something like /posts?category=a&tag=b Should filter posts with a category and tag b...

Make an object with the same structure but modified values

I'm trying to do some cool stuff with .mdx as strings being parsed in getStaticProps and got to an ok point but everything went to shit when I tried to put those strings into an object since I need to serialize them and want to keep the object structure for that sweet autocomplete in the frontend. Long context out of the way, let's say I have: ``` const obj = {...

React Native + Web + Next.JS

Does anyone know a good boilerplate template for react native + nextjs? Trying to find a working one but no luck so far.

Store data in object format in prisma (MongoDB)

How to do this in prisma model ? I'm using mongodb

How to create object in prisma models (MONGODB)

I want to create an object in my model named orderData:
orderData = {name, email, service, note}
orderData = {name, email, service, note}
I want to create a property name orderData and these properties will be there...