fisher
fisher13mo ago

Cannot read properties of undefined (reading 'trpc')

I keep getting that when trying to make an api request with my next.js page. I am using the latest Next.js version with app router enabled.
4 Replies
fisher
fisher13mo ago
nevermind, fixed!
Oscar T.
Oscar T.12mo ago
Hey @j.fisher! I'm getting the same error, how did you fix it?
Oscar T.
Oscar T.12mo ago
No description
Oscar T.
Oscar T.12mo ago
Just solved it, I was trying to use the api imported from server on a component with the use client directive, and I fixed it by switching the import to the client, like this: import { api } from '@/trpc/client' Got the idea from this repo: https://github.com/trpc/examples-next-app-dir
GitHub
GitHub - trpc/examples-next-app-dir
Contribute to trpc/examples-next-app-dir development by creating an account on GitHub.
No description