Data Fetching in NextJs with High Order Functions

An advanced pattern that speeds up the development of pages by reusing common data and behavior requirements.

In Web Applications, different pages often share data requirements such as information for the currently logged-in user — and behaviors such as authorizing or not a user to see a page.

Imagine a Social Media App and consider that all the authenticated pages have the following requirements:

  • The user must be logged in to see the content, otherwise, he is redirected to the login page



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Fernando Abolafio

Fullstack Engineer — Modeling Revenue in code @GrowblocksHQ — Tweeting about Web Dev/React/Remix/NextJs — Software Architecture — Blockchain Tech/DAO/Decred