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
nevermind, fixed!
Hey @j.fisher! I'm getting the same error, how did you fix it?
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-dirGitHub
GitHub - trpc/examples-next-app-dir
Contribute to trpc/examples-next-app-dir development by creating an account on GitHub.