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`,
},
}
}
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
6 Replies
barry
barry2y ago
you dont use it in gssp
cje
cje2y ago
Christopher Ehrlich
YouTube
Advanced tRPC - Callers, functions, and gSSP
Repo for this video: https://github.com/c-ehrlich/you-dont-need-callers If you want to use schema in the frontend, they cannot be imported from the same file as things that run specifically in the backend. One solution would be to put them into a procedureName.schema.ts or similar file. tRPC: https://trpc.io/docs Create T3 App: https://crea...
cje
cje2y ago
gssp starts at like 4:30
batata
batataOP2y ago
will watch the video appeared on my feed yesterday, was too lazy to watch it lmao. lesson learned really nice video, i hope you keep publishing content!
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
cje
cje2y ago
thanks! the fakeprisma thing was just something i made up for this video https://github.com/c-ehrlich/you-dont-need-callers/blob/main/src/server/db.ts
GitHub
you-dont-need-callers/db.ts at main · c-ehrlich/you-dont-need-callers
Contribute to c-ehrlich/you-dont-need-callers development by creating an account on GitHub.
Want results from more Discord servers?
Add your server