#02 – Data Fetching – Learn Next.js

Next.js provides three functions to fetch data for pre-rendered pages: getStaticProps(): Used for static generation (pre-rendering technique)Fetches data at build-timeWhen an async function getStaticProps() is called from the page component, the next.js will pre-render this page at build time using the props returned by that function (see Examples)The context parameter used as an argument of getStaticProps() function is an object containing following parameters (see details here):paramspreviewpreviewDatalocalelocalsdefaultLocalegetStaticProps() function returns an object with following parameters (see details here):props (required)revalidatenotFoundredirectImports used inside the getStaticProps() function are not bundled for the client sideServer side code can be written inside the getStaticProps() function e.g. to...
forward

#01 Introduction – Learn Next.js

Next.js is a framework used to develop production ready React applications. Next.js provides many useful features e.g. pre-rendering, smart bundling, dynamic file-based routing, route pre-fetching and many more. In this blog post, we have discussed the prerequisites, how to create next.js application, next.js pages, and pre-rendering techniques.

forward