Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
2 replies
xegld

useQuery runs on CSR?!

Hi!

When I try to build my next app, the useQuery hooks from my pages are triggered and fail with TRPCError (because you have to be authenticated).

I am using
ssr: false
and my pages don't use getStaticProps or getServerSideProps

The useQuery should run only on client side as mentioned in https://nextjs.org/docs/pages/building-your-application/rendering/client-side-rendering

Any idea how to debug/fix this?

const Page: NextPage = () => {
const {data} = api.test.list.useQuery()

return (<>
   {data?.map(item => <p ...>{item.title}</>)
</>)

}
Learn how to implement client-side rendering in the Pages Router.
Rendering: Client-side Rendering (CSR)
Was this page helpful?