Skip to Content

Navigation Hooks

Hooks for navigating between pages and reading page state.

useNavigation()

Navigate between pages, read current page state, and track progress. Only re-renders when the current page changes.

const { goToNextPage, goBack, goToPage, currentPage, progress } = useNavigation() return ( <div> <p>Step {progress.current} of {progress.total}</p> <button onClick={goToNextPage}>Continue</button> </div> )
PropertyTypeDescription
goToNextPage() => voidEvaluate routes and navigate to the next page
goBack() => voidNavigate to the previous page in history
goToPage(pageKey: string) => voidJump to a specific page by key
currentPagePageState | nullCurrent page object
pageHistorystring[]Array of visited page keys
progressProgressNavigation progress

PageState

FieldTypeDescription
keystringPage identifier
namestringDisplay name
typestringPage type (default, checkout, paywall, etc.)
slugstringURL slug
indexnumberPosition in the page list

Progress

FieldTypeDescription
currentnumberCurrent step number
totalnumberTotal number of pages
percentagenumberProgress as 0-100

usePageData()

Read page-level system variables. Re-renders on navigation.

const { currentId, progressPercentage, startedAt } = usePageData()
PropertyTypeDescription
currentIdstringKey of the current page
currentIndexnumberZero-based index of the current page
currentnumberOne-based page number
totalnumberTotal page count
progressPercentagenumberProgress as 0-100
startedAtnumberTimestamp (ms) when the current page was entered
Last updated on