Theo's Typesafe CultTTC
Theo's Typesafe Cult3y ago
8 replies
batata

tRPC in getServerSideProps

this is the code im writing in the getServerSideProps
export const getServerSideProps = async (context: any) => {
  const session = await getSession(context)

  const { id: shopId } = context.query

  const shop = trpc.shops.getById.useQuery(shopId)

  if (!shop) {
    return {
      redirect: {
        permanent: false,
        destination: `api/auth/signin`,
      },
    }
  }
javascript

getting this error "TypeError: Cannot read properties of null (reading 'useContext')"
I enabled ssr in the utils/trpc.ts file, still same error
Was this page helpful?