Member-only story

How To Choose Data Fetching Strategies In NextJS

Explained with real-world examples

Mohammad Faisal
Better Programming
4 min readAug 3, 2021

One way signs going in different directions.
Photo by Brendan Church on Unsplash

NextJS is a framework that we React developers love and admire. It’s high in demand and very, very powerful.

But when you start to learn this you will see that ReactJS and NextJS mainly differ in the capability of pre-rendering. Which can be a little tricky to grasp at first.

There are multiple strategies for us to choose and it gets confusing at first to apply the correct solution in the correct place. We will take a real-life application and understand which strategy works best for which scenarios.

Let's get started.

The Functions

I hope you already have a basic understanding of NextJS. If not, I would suggest you read this article first.

The special functions that are used for pre-rendering in NextJS(but not present in ReactJS) are:

  • getStaticProps
  • getStaticPaths
  • getServerSideProps

We will see in which scenarios you can apply these functions and also learn the best practices.

We Are Talking About an Ecommerce Website

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Responses (3)

Write a response

Recommended from Medium

Lists

See more recommendations