logo

React Page Tracker

A lightweight, zero-dependency library providing accurate navigation tracking, fixed document.referrer value, and complete history support for React frameworks.

Documentation

Installation

npm i react-page-tracker

Usage

In any client component:

const state = usePageTrackerStore((state) => state);

And you will get following values:

{"pageIndex": 0,"referrer": "","pageEvent": undefined,"isFirstPage": true,"isLastPage": true,"pageHistory": [],"pageHistoryLength": 0,}
🚀 An awesome use case: Magic Back Button in shadcn/ui expansions