Home
Basics
Introduction Environment setup Project structure Pages CSS in NextJS JavaScript in NextJS Layouts Data Fetching Routing API Routes Metadata and SEO Environment Variables OptimizationsAdvanced
Dynamic Importing Blog using md files Authentication in NextJS Mongodb and NextJS Stripe and NextJSMiscellaneous
Deploying NextJS app on Heroku NextJS Templates NextJS Interview QnAData fetching in NextJS
Data fetching can be done in below ways.- Client Side - use fetch api in useEffect or SWR library
- getServerSideProps - pre-render this page on each request
- getStaticProps - (Static Site Generation - SSG) - pre-render this page at build time
- getStaticPaths - Used for pages with dynamic routing
export async function getServerSideProps(context) {
return {
props: {}, // props to be passed to page component at request time
}
}
export async function getStaticProps(context) {
return {
props: {}, // props to be passed to page component at build time
}
}
Web development and Automation testing
solutions delivered!!