kyle-mccarthy / nest-next

Render Module to add Nextjs support for Nestjs
MIT License
643 stars 91 forks source link

Are getStaticProps and getServerSideProps supported? #62

Open baleksandr48 opened 3 years ago

baleksandr48 commented 3 years ago

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 commented 3 years ago

Does somebody has any minds about this?

kyle-mccarthy commented 3 years ago

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.

DiFuks commented 3 years ago

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

DiFuks commented 3 years ago

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