react-page-tracker
Version:
A lightweight, zero-dependency library providing accurate navigation tracking, fixed document.referrer value, and complete history support for React frameworks.
18 lines (17 loc) • 634 B
TypeScript
export type PageEvent = 'forward' | 'back' | 'push' | undefined;
export type PageTrackerState = {
/** current page index */
pageIndex: number;
/** correct `document.referrer` */
referrer: string;
/** whether the current page is the first page */
isFirstPage: boolean;
/** whether the current page is the last page */
isLastPage: boolean;
/** whether the user navigated to the page via browser back/forward buttons or by clicking a link */
pageEvent: PageEvent;
/** history browsing record */
pageHistory: string[];
/** total page history length */
pageHistoryLength: number;
};