Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

can we use getServersideprops in any component in next.js

You cannot use getServerSideProps in non-page components. You can either pass the prop from Home to HomeSection or create a context so the value can be available globally from the component tree

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

https://nextjs.org/docs/basic-features/data-fetching#only-allowed-in-a-page-2
Source by nextjs.org #
 
PREVIOUS NEXT
Tagged: #getServersideprops #component
ADD COMMENT
Topic
Name
8+3 =