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

Validation Errors. What’s the best approach?

Do you throw an exception? Do you return an object like ‘{ data: {}, errors: [] }’? How would you best handle this? It’s also a requirement that all the validation takes place to return a list of the items that are invalid. Any resources on this concept would be much appreciated too!

onchange isnt triggering when a search query is passed to an element

when my search query is not null: ?value=something then i want to automatically think of it as an onchange in a form input. as when i currently pass in the value, the on change isnt detecting...

Database Recommedation

To put simply I have familiarized my self with Nextjs, Typescript, Tailwind and Vercel. I am now ready to get into Prisma but I am having trouble choosing a DB. I use to use MongoDB a lot, but I believe I was heavily limiting my self since it is a non-relational Database system. Now that I have clients and my business is growing slowly I would like to use one I can scale well with. What would you guys recommend me?

Set cookies to a different domain

Hi guys, I'm trying out Clark for a multi-domain SaaS project in Next I'm building and I need some help to better understand where I can fix some cookie problems 🥁. To make it simple this app is divided in three parts: - the root domain, example.com, with all the landing page and the marketing stuff - the account sub domain, account.example.com, where the auth is located (signin/signup pages, etc) and where clients can do some settings stuff...

Superjson not working in createProxySSGHelpers?

Hey all. Having this weird behavior when trying to fetch data server side where superjson is failing to serializing a DateTime in SQL. IIRC Superjson should handle this, and it does when fetching data from the client, but it is failing when I'm using createProxySSGHelpers from the server side even though I am passing in the superjson into the transformer. Is anyone else seeing this behavior?...

default NextAuth middleware and custom middleware conflicting

```ts import { NextResponse, type NextRequest } from 'next/server'; export { default } from 'next-auth/middleware'; ...

Are sever components running on an actual sever? Can someone explain?

Next js question. Why can’t we import sever components into client components directly? I know we can pass sever components as props, but why only this way?...

Omit properties function typescript

Hey, I'm trying to write helper function to easily omit some properties form my object, but I can't really get correct return type that omits properties i passed throught. Right now it returns object that has type of the same object i pass in parameter. ``` export function omit<T extends object, U extends keyof T>(obj: T, ...props: U[]) { const result = { ...obj };...

Integrating Google OAuth with NextAuth.js: how to get Client and Token from google login

I would like to integrate Google OAuth with NextAuth.js and have an endpoint at /api/signin/google-oauth. To successfully authenticate a user, I need to provide the following data in the request body: "email": "[johndoe@example.com] " "entry_event_id": "string" (I already have this value) "google_client_id": "string"...

Handling il8n in Next 13

Does anyone have a better solution for handling internationalisation in next 13 , I have gone through few solutions in the web and everyone is suggesting to use [lng] dir in the root and include all components inside, but making them causes every route to have lang code , can we do anything better without including the lang code

Can this function be improved performance wise?

I am using a function to wrap part of texts that contains links, emails and urls with a component that links you in the appropriate way in React Native but since this could be used for rather long texts I am wondering if you see any potential performance improvements that could be made? ```ts const renderTextWithLinks = (text: string): React.ReactNode => { const allWords = text.split(' '); return allWords.flatMap((word, index) => {...

How to use trpc inside next.js middleware

What is the best way to use trpc inside next.js middleware

How to set cookies from trpc backend using next.js

I need to set a cookie from the backend of trpc in next.js

Building T3 app with Docker. Image access issue (sharp).

I have a quite simple app based on T3 template. I want to deploy it with Docker, so i'm building Docker image as it suggested in docks. Image are building successfully, app runs, but image optimisation do not work. In console i see error that i need to add "sharp" npm package explicitly to make it work. After installation, <Images /> that are added as usual works fine, but images that are added in a way that are shown on screenshot - fails with 500 error, and server die. In console i see socket errors. In very-very rare cases 1-2 of 5 images loads, but in next run of same image they all can fail 😕 When it is deployed to Vercel - everything works fine. (no errors, server alive, everything 'webp' When i replace Image -> img in that map, everything works fine. (This images are not optimised (still png), least images are transformed png -> webp)...

Website "tutorial"

Hey Im looking for good js library to create website tutorial. When you first time open some web app, it will "show you around". Where is what and what you can do. I tried to use Popper.js and Tippy.js but I got lost in using it and I dont thing its the right tool for the job. Because I want sequential tutorial that wont show ever again after playing first time.

how to use client side rendering in the next js ? i didn't find anything in the docs ?

hello how to use client side rendering in the next js ? i didn't find anything in the docs ?...

Unable to query data

I am trying to query learning targets from a specific test but I don't know why it won't let me. Any help? I have added the db schema, the trpc protocol, and the html code.

How to fetch data from NextJs API folder using tanstack query on button click

Hello, so I'm using tanstack query (first time ever) to fetch a NextJS API route triggered by a button click that calls the Clerk Dev backend API to delete a user. The thing is, that sometimes the API's response is successful, sometimes it is not, and since I'm new with this library I don't know what I should do or where to start. Here is my code:

How to Install Forked Next Auth from GitHub

I forked the next-auth repo and made some changes to fit my needs. How can I install this repo with NPM from my forked github repo? I'm not very familiar with Turborepo

Auto populating new tables on user sign in

I created two models that are related to User in the same way Account and Session are. When a new user signs in User Session and Account all get populated with data, but GameData and UpgradeData dont seem to even with default values supplied. Ive looked through trpc.ts and auth.ts to see if I need to add anything in those files but I dont see anything related.