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

How to reduce cold start times with tRPC api

My app was built using t3 stack and for the most part its great but it has one problem that i havent been able to solve / understand yet. Currently, my tRPC api has a ~10s or so cold start time in my vercel deployment. When the api isnt cold starting the api requests take a second or 2. This is ruining demos whenever I try to show people. Here are the things I know / figured out: - The cold start time is only bad for api requests. The UI never seems to have a problem loading quickly. - Vercel's function logger shows the Init Duration as > 7s - Online i've seen people complaining about 1-2 second cold start times so i feel like i must be doing something totally wrong...

How to redirect from login page with trpc's SSR enabled?

Any simple solutions for redirecting unauthenticated users to /login and authenticated users from /login to / with trpc's SSR enabled, i.e., without the use of getServerSideProps?

Delete file from s3 using presigned urls

I am trying to delete files from my bucket using a presigned url, so far this is my api handler: ```ts import S3 from 'aws-sdk/clients/s3' import { NextApiRequest, NextApiResponse } from 'next'...

Recommendations on feature flag library for t-3 app?

I saw on Vercel's documentation that they recommend optimizely. Has anyone had experience with it or have other recommendations?

Easy way to clear database?

Noob here. My schema is massive and I don't want to have to manually type in all of my model names + deleteMany(). Doing that is also painful because a lot of times you have to delete things in a certain order. I'm using prisma db push instead of migrations. Anyone have an easy ts code snippet that will just completely wipe my database so I can seed everything again?...

NextAuth + GitHub Provider refresh

is anyone using NextAuth with the GitHub provider in a real app? From what I understand, sessions don't get renewed properly after a few hours unless you make some changes, see: - https://next-auth.js.org/providers/github - https://docs.github.com/en/apps/creating-github-apps/authenticating-with-a-github-app/refreshing-user-to-server-access-tokens#response ...

should i just make a REST api for that?

i have a simple function: isTrueOrFalse it returns true or false depending on how the server feels ...

React Native + Next.js API server deployed on vercel ?

Is it possible to use Next.js and just use it's API routes to create a backend server which can be deployed on Vercel which can then be used with react native. When I say used with it will be using tRPC. I cant find any info on if this is even possible, there aren't any articles or tutorials explaining how to....

how to serve image from digitalocean spaces(s3)

im able to uploads file to the bucket but i cant serve the file to the frontend(i think by default digitalocean spaces are set to private) so i create presigned get url like this. but is it a good practice? any suggestion? thanks in advance

Single nested admin route catch-all for all pages?

How can I setup my file-based routing to be something like: pages index.js about.js contact.js...

PostgreSQL: Best pgAdmin4 Alternative?

Very frequently I need to query the DB, I have pgAdmin4 deployed to web and it works fine but is tow major issues are driving me to find a new solution. 1. Autocomplete just sucks. 2. Query editor is lacking basic functionality’s (can’t move up rows for example). ...

NextAuth - User stays logged in after token is expired

Right, I understand that maybe I should write some sort of callback or something that prompts the user to log in again, or maybe to refresh the token.. but I don't understand why this happens.

React-Dropzone, useState & dnd-kit struggles

What I want to achieve is the ability to drag image previews to change the order of the images, ie. something like this: https://codesandbox.io/s/dndkit-sortable-image-grid-py6ve?file=/src/App.jsx The images & their preview come from a react-dropzone component. There is a solid chance this is irrelevant to my issue but mentioning it to be sure. My initial plan was to have a state in the react-dropzone component inside of the onDrop: that will populate the useState into the following shape: { id: number, src: File }. This approach is similar to the example in the first codesandbox. but I don't see how I can do this without a useEffect, which feels overkill since this is really close to what I want to achieve: https://github.dev/HamedBahram/dropzone...

Export a Planetscale database.

Hello everyone, this question is related to Planetscale. I have a Planetscale db with 2 tables. Students and certificates. Each student has one certificate. Is there any way to export the data in order to read it with Excel?...

TRPC useQuery keeps refetching when switching pages? How can I cache the data on the client?

I recently migrated my project from CRA + React Query to T3 stack. I'm finding that on my client, all my queries called using useQuery are not being cached correctly. The whole React Query cache gets wiped when I go to a different page. In CRA this wasn't an issue, the query was cached until I invalidated it or it ran out of cache time. I'm not sure if there's an option I need to pass to the useQuery calls?...

Remote Markdown Best Practices

Any best practices when fetching remote markdown from a headless cms? If there is a project/article/video which covers this topic, i'll greatly appreciate it. Or some common mistakes / design patters to use to create maintainable and better code. Thanks!

Incorporate Rust into t3 stack

Im wondering if there is a good way to incorporate rust into a t3 app? Want to experiment writing some apis in rust and hopefully seeing some performance boosts #blazinglyfast 🙂...

How to replicate React Router Outlet like utility for Next.js?

A module in my Next.js application has a sidebar. I want to navigate to those paths without re-fetching the same data (that belongs to the parent component) from the API. The routing system of Next.js is restricting me to achieve the same. Is there any way I can replicate react-router "Outlet" like utility in Next.js? Thanks!...

pre-defining data in SSR?

Curious — can you use NextJS middleware to push data into getServerSideProps? Let’s say you have some global variable that gets reset every page refresh — but you need to populate through some API or pass it from the client. What’s a good way to populate the server with that global variable before it reaches a pages SSR