Home > OS >  Is it possible to use getStaticProps and getStaticPath in a page component where you use dynamic rou
Is it possible to use getStaticProps and getStaticPath in a page component where you use dynamic rou

Time:01-27

So basically I have a fully SSG app where i can not reach the backend in build time, and every data are permission and user specific, therefore i can not specify the paths in the getStaticPath method which i must use in a dynamic routed component if i want to use getStaticProps. I tried to use fallback 'blocking' but resulted in the error : Pages with fallback enabled in getStaticPaths can not be exported. I really want to use getStaticProps on that page so i could improve on the performance.

CodePudding user response:

where i can not reach the backend in build time, and every data are permission and user specific,

You are describing getServerSideProps, your site is not an SSG.

CodePudding user response:

As per you situation you need to use getServerSideprops and for performance optimization you can just use some kind of caching on server-side api calls like you can use react query and hydrate it with frontend this will boost your performance.

React query docs with next js SSR

  •  Tags:  
  • Related