Data Fetching in NextJs with High Order Functions

Fernando Abolafio
6 min readJun 6, 2022

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

--

--

Fernando Abolafio

Programmer — Modeling Revenue in code @GrowblocksHQ — Writing about Web Dev/React/Remix/NextJs — Software Architecture