Use yarn next dev
or yarn dev
commands to run the app locally.
Use yarn build && yarn start
comman to run in production mode.
We can use getInitialProps()
only inside pages, it's part of NextJS
The fetch
method doesn't exist in NextJS, we need to add library isomorphic-fetch
yarn add isomorphic-fetch
It has to be imported from 'next/link' To use it, we need to include href as an attribute, and include an tag to make it work. When you click on the link, NextJS will call the part of js needed to render that new page. Not all the dependencies again.
The method prefetch doesn't preload getInitialProps, only the payload (HTML, CSS, JS) The method only workd in PRODUCTION, not in development
To make several request at the same time.
Here we can add all the things related to the of a regular HTML You can include things like title and metadata.
Next help us to handle the server error, only passing the statusCode as an attribute
The res
prop tell us the status that server replied
You can also create custom error with a file _error.js inside pages