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

React Query For Asynchronous Data within Sanity Studio

I'm using the sanity studio to manage my Sanity CMS. I was able to configure a custom component that fetches data for a specific field in my sanity schema with this guide https://www.sanity.io/schemas/asynchronous-list-options-component-05f63a29. But it is using a normal fetch request which is not optimized. I thought of utilizing react-query for this but i was not able to figure out a way to wire react-query to the sanity studio client. Any input will be appreciated,...

Next Auth or Clerk

So I want to use Clerk, should I pull out Next Auth and replace it with Clerk, or do they work OK together?

Implement a forum on website

Im looking to add a forum onto my website, Do you guys know of any smart and easy way to do this, that has good integration to nextjs/t3 stack?...

Bundling Prisma with my Express app

Hi everyone, I currently have a project with Typescript, ExpressJS, Prisma and want to bundle with with whatever bundling tool there is out there. Literally ANY at this point. Also, to include all the node_module dependencies so I can simply export 1 large js file with its various config files. ESBuild wants me to keep my environment variables in my OS, which I do not find practical for my basic deploy via SSH and shell script. Parcel...doesn't work at all. I understand it's mostly for libraries....

TRPC good practice, single schema, multiple similar updates.

I'm using TRPC and zod. I have two similar forms which update the user object in my database. On one I want to update firstName and lastName....

TRPC Context

Hi guys! I was wondering when the trpc context is created? is it created at every request? I was wondering because I'm adding a query to my database inside my trpc context just so I get additional user info that is needed in my routers or do we have a better way to do this instead? Thank you!

Typescript Inference for getServerSideProps-like function

So I'm having some issues with type inference on typescript that I cannot wrap my head around. It's something like this: https://tsplay.dev/WzxAQN. How do I make it infer the correct type without manually specifying the return type?...
Solution:
I managed to find a solution, if anyone is interested: https://tsplay.dev/Nr9KVw

[Solved] How to get clerk userId in a publicProcedure?

I need to get the authenticated user's id. I tried to use getAuth but I need to pass "req" as a parameter. Now the thing is, I don't have req in my publicProcedure. I only have input and ctx. Ctx only has prisma and input is just the input I passed to the query. Do you guys know how to get the authenticated userId???...

reading 'useMemo' error

hello, i've a project with nextjs trpc and prisma. after yarn build and then copy to iis host i get TypeError: Cannot read properties of null (reading 'useMemo') error. scripts: "build": "prisma generate && next build", "start": "node server.js". i finished project and want to host it at my windows server - iis. watching this video https://www.youtube.com/watch?v=HLsx0iraA-Y&t=1s...

turborepo: bin of local package not resolving properly

/packages/next-typesafe-url/package.json ```json // ... "bin": "./dist/cli.js", "typings": "./dist/index.d.ts",...

publicPages not working.

```import type { AppProps } from "next/app"; import { ClerkProvider, SignedIn } from "@clerk/nextjs"; import { useRouter } from "next/router"; import SignUpPage from "./sign-up/[[...index]]"; import SignInPage from "./sign-in/[[...index]]";...

How do i properly set up nextjs external pages/api/* routes using trpc?

I have a working application, now for testing I want to create a few pages/api/* routes to see the raw data i get before pushing into a component. I created pages/api/lessons with this content: ``` import { trpc } from "@acme/app/utils/trpc";...

Next font sever/client mismatch in app dir

Hi trying to include a style tag which sets css vars based on next font but get the following error ``` Text content did not match. Server: ":root { --font-p: 'Montserrat_656221', 'Montserrat_Fallback_656221'; }" Client: ":root {...
Solution:
It looks like it’s encoding the '. What happens if you dangerously set html for var styles

Typescript function parameter into returnType

Here's my function: ```export const useSomething = <Data extends object>( func: (values?: Data) => Promise<any>, name?: string...

'Component' cannot be used as a JSX component.

```ts import { AppProps } from 'next/app'; import { api } from '~/utils/api'; import '~/styles/globals.css'; ...

Firebase deployment

I have a question so we have T3 application and we want to deploy it to Firebase we are currently running firebase deploy command but the deployed website is not able to use any kind of backend or db. When we run firebase deploy it jusr runs and creates a SSR function and the website is being deployed but when we actually make any kind of TRPC call like normal hello world example is not working in firebase deployment. We don't have a seperate functions folder in our project we have strictly followed folder structure of T3 docs so there is a src/server in which there are tRPC routes defined....

What's the best way to store translation data for an app?

Currently we have everything hardcoded in English. We have some translators that will write out the translations but I'm wondering what the best way is to store this data and make it easy to implement. My initial thought was a JSON file and have the data be structured like ENG -> introBlock1 -> title: 'title goes here', subtopic1: 'something here'. BTW this is a very tiny app not and not for consumers.

react-speech-recognition with Next.Js

Hey ya'll, anyone have any experience using the react-speech-recognition library with next.js? I cant seem to get my grammar setup, and cant find steps anywhere. Anyone able to help?

I need a bit of help understanding trpc

I've got everything set up as per the next-auth starter. I've got a query that gets me an index of things with ids, and then I need to loop over those things and use each id and call another query per item. Finally I want to make a state of { thingWithId, ListofThings } I can't find a way to do this:...