Home > Software design >  How can I use getServerSideProps in components
How can I use getServerSideProps in components

Time:07-08

I need to use getserversideprops in components like I used in the pages. but I'm stuck how can I pass the sanity data into components?

edit: solved I was missing the props :)

CodePudding user response:

According to Next.Js docs,

getServerSideProps can only be exported from a page. You can’t export it from non-page files.

So, you have to call getServerSideProps inside a page component and not any other component. You can use getServerSideProps inside a page, which wraps your component and pass data down to component.

  • Related