nest-next icon indicating copy to clipboard operation
nest-next copied to clipboard

Are getStaticProps and getServerSideProps supported?

Open baleksandr48 opened this issue 4 years ago • 4 comments

In example I see that you use getInitialProps function. But in the official doc there is an info that it's better to use getStaticProps and getServerSideProps.

I downloaded your example, installed last version of next, replaced getInitialProps -> getStaticProps and started an app.

export const getStaticProps = async (arg) => {
  // arg is {}
};

What I see? The argument is empty object.

After that I opened this official doc (https://nextjs.org/docs/advanced-features/custom-server) and found the next info:

A custom server will remove important performance optimizations, like serverless functions and Automatic Static Optimization.

If I am right, it's exactly what this library do - replace next's server with custom one (from nest js). So, am I right that if I choose this library, then there will be no ways to cache generated pages and I will have to render it on every request?

Or maybe you have some ideas and in the future versions you are going to implement it?

baleksandr48 avatar Sep 27 '20 15:09 baleksandr48

Does somebody has any minds about this?

baleksandr48 avatar Oct 13 '20 09:10 baleksandr48

getServerSideProps works and can replace the getInitialProps call ; however, I am unsure if getStaticProps will work. I would be curious to see if it works with the beta passthrough feature.

kyle-mccarthy avatar Oct 13 '20 20:10 kyle-mccarthy

@kyle-mccarthy How does getServerSideProps work? In ctx.query I am getting an empty object and my nest controller is not being called

DiFuks avatar May 16 '21 11:05 DiFuks

It is worth clarifying that everything works fine with server rendering. This problem occurs when switching between pages and requests like /_next/data/development/Main.json

DiFuks avatar May 16 '21 11:05 DiFuks