The best you can do, with NextJs already built-in integration, is to use the package document-page-counter, download it from npm , using npm i document-page-counter
. Also, check the doc or the github repo, you will find there a demo project for an integration with NextJs.