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 13.4 app, converting _app and _document to layout.

How would I go about changing my _app to work with the root layout in my app directory? _app.tsx ```import "~/styles/globals.css"; ...

Implementing an anonymous "like"-function for my webpage

I'd like for my users to be able to "like" my blog posts as an extra point of feedback for me to consider while writing. This should be done without creating an account as I'd expect no one to invest that much effort into my website. For now I've settled on using some hardware + software characteristics to create an anonymous fingerprint of a users browser in order to make a small attempt at weeding out duplicate likes. Is there any obvious negatives to storing these fingerprints as plain text in my DB? They're not specific enough to identify a user (nowhere near) and I can't store them hashed since I have no username or the likes to search the tables with. This approach eliminates the need for cookies (which I would like to stay away from if possible) and would give me "good enough" protection against refreshing and liking again....

How do I make pretty-ts-error appear before original error msg?

Scrolling down everytime is pretty annoying. I'm pretty sure I saw how to do this once but I forgot where.

env variable is undefined

Hi people, I'm having issue that my env variables in config.drizzle.ts are being undefined, even though they exist in my .env file, If i try to hardcode them, they work fine. if I try to console log them in server component they have expected value...

Any idea how to use imports outside of a module? Trouble understanding this error:

What does this error mean by cannot use import statements outside a module? This is a mdx blog with contentlayer, and it doesn't like me using the useMDXComponent function.
No description

Detect a change to the session and update accordingly?

I'm trying to integrate Intercom with my create-t3-app and having some difficulty with users logged in vs visitors. I can get Intercom to update when a user logs in or out, but I'm trying to figure out how to connect it to the actual session - if a logged in user returns to my application for example. I also have an issue where Intercom clears the users data when they navigate to a different page when they're not logged in....

how to use useChat From vercel.ai with trpc router?

what api endpoint should I specify to correctly have access to the data in the chatRouter?
No description

Pusher with Vercel or Netlify?

I have a T3 stack application working locally that sends and receives real-time notifications perfectly well on localhost:3000. When deploying to Netlify or Vercel, the pusher messages don't seem to send, or when they do, it takes 10-30 seconds to send/receive the messages. Just some context. I make API calls with trpc and the api sends a pusher trigger like this:...

SSG not pre-fetching data

So I am following the twitter clone video. The profile page is created entirely through static site generation. I really want to understand SSG in general, so why is it that when I try to access the profile page, the Errorpage with the 404 flashes for one second before showing the actual content ? I understant that this is the fallback page which should only show when there is for example no user. Moreover because we use SSG, the user is basically null for a split second. Even in the video and t...

Jest Tests with React and CRA.

I've run into a problem using jest and using includes. If I want to include some external library reference in my test, and I try to import in the spec file, when I run the tests, the import resolution always fails with a module not found error. I've tried messing with various parameters in package.json to aid path resolution, but nothing I've tried has worked. I even created a sample jest app using the react example on the website, and the same problem occurs with a brand new empty project. T...

ReferenceError Help in next13

Attached is my error as well as my next.config.js file. I have no idea what this error means and I'm having trouble finding a solution online.
No description

can anyone help me to install pnpm on debian

im using debian bookwork and bot npm and npx install result in error. can anyone help me

Performance concern on Nextjs 13 layout files

Hello, I would like to ask the following questions regarding this code ```typescript export default async function AdminPagesLayout({ children }: PropsWithChildren) { if (await isAdministrator()) return <>{children}</>;...
No description

Am I supposed to handle type-related errors on client side? (TRPC)

I'm using react-hook-forms, I'm just getting the data which I mostly assign to (string) as it'll get validated anyways on the server but the LSP keeps nagging that I have to validate the form before submitting it isn't it supposed to be server-side and that's it? What do you guys usually do in such case? // @ts-ignore and keep moving or actually fix it?...
No description

callbackUrl=%2F&error=OAuthAccountNotLinked

Anyone run into this before with Google Provider? Heres the link to the repo: https://github.com/DollaHane/PepperMint. The user is created in the db on sign-in but I've got no session. Also the "session", "account" and "tokenVerification" tables are still empty after sign-in. This is my redirect URI: http://localhost:3000/api/auth/callback/google

I got some free time while on bench, who wants some JS help

I'm on bench, this is my first post and want to help people with debugging or general help, so link push your questions

getQueryKey have no prev data

Why is prev undefined? I want to refresh data without access db. May I get some help please....
No description

api.withTRPC doesn't show isLoading or isRefetching on cache invalidation

I am using the default t3 app with Prisma, next auth, trpc and typescript currently , it's my first time with next in general so still getting the hang of things so bare with me. I've wrapped one of my pages (/vm) with api.withTRPC export default api.withTRPC(VMS) so that the data is fetched for queries on the server before returning the page (At least this is my understanding, follow up queries are streamed still). However, in another component, I've attempted to invalidate my query with the following code ```ts const utils = api.useContext();...

creating fullstack dashboard with nextjs

Hey so i have already had this project set up but with react front and nestjs backend github link I wanted to rewrite it to nextjs and someone recommended me t3-app to create full stack app with nextjs so here i am asking how to do API in this cause the things it generates is kinda overwhelming for a beginner, can someone point me where to start? should i use tRPC?...

Infer useQuery .data type from TRPC

Hello! I am using a lot of joins in my Prisma/TRPC queries, resulting in some pretty chunky union types being returned, see the attached screenshot for an example. As you can see useQuery returns a type with a bit of nesting of a bunch of Prisma types. This works great for intellisence when working directly with listings.data, however, if I want to use that type somewhere else (type def for FC props) I need to create a new type just to use it elsewhere. In the screenshot you can see above I have created a type which is exactly the same as the type being returned by useQuery. This is okay, but pretty hard to maintain, if I change the query to return something else, that type is now invalid Im sure the solution is easy I just cant figure it out. Something like inferredType = typeof listings.data... something like that?...
No description