nextjs-with-react-intl icon indicating copy to clipboard operation
nextjs-with-react-intl copied to clipboard

How to use `getServerSideProps` or `getStaticProps` instead of `getInitialProps`

Open arunmenon1975 opened this issue 5 years ago • 0 comments
trafficstars

My current project has a need to support more than one locale. I am also trying to have as many pages SSG'd or SSR'd as possible i.e with AMP optimisations. Having the getInitialProps in the _app more or less rules out SSR as is the case here.

The official example does it via _document but i was getting some error or the other when integrating it onto my project (serverless). Before another attempt in a fresh project i searched around a bit and came across your project. I find that your example is simple enough to understand, integrate and learn from as well.

Do you have any suggestions or tips to either move out the getInitialProps from _app or use getServerSideProps. I am assuming getStaticProps wont really be a solution in this case.

EDIT:

Incidentally, the official example does use getInitialProps in _app.ts as well.

arunmenon1975 avatar Sep 30 '20 16:09 arunmenon1975