Documentation Index
Fetch the complete documentation index at: https://mintlify.com/eds2002/react-native-screen-transitions/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheuseHistory hook provides access to the global navigation history store. Use this hook to query recent screens, track navigation paths, or build features that depend on navigation history across your entire app.
Import
Usage
Return Value
Returns aUseHistoryReturn object with the following properties:
The full history map. Keys are screen keys, values are history entries containing timestamp, route info, and navigator context.
Get N most recent history entries, ordered with most recent first.Parameters:
n(number): Number of entries to retrieve
HistoryEntry objectsGet history entries for a specific navigator, ordered with most recent first.Parameters:
navigatorKey(string): The key of the navigator
HistoryEntry objects from that navigatorGet the navigation path between two screens for multi-waypoint interpolation.Parameters:
fromKey(ScreenKey): Starting screen keytoKey(ScreenKey): Ending screen key
fromKey to toKeyGet a specific history entry by screen key.Parameters:
screenKey(ScreenKey): The unique key for the screen
HistoryEntry if found, undefined otherwiseGet the most recent history entry (useful for forward navigation).Returns: Most recent
HistoryEntry or undefined if history is emptyHistoryEntry Type
Each history entry contains:screenKey(ScreenKey): Unique key for the screenrouteName(string): Name of the routenavigatorKey(string): Key of the navigator containing this screentimestamp(number): When this entry was createdparams(object): Route parameters
Examples
Display Recent Screens
Track Navigation Path
Filter by Navigator
Check if User Visited a Screen
Build Breadcrumbs
Analytics Tracking
Prevent Back Navigation to Specific Screens
Notes
The history store subscribes to navigation changes globally, so
useHistory can be called from any component, not just screen components.History entries persist throughout the app’s lifecycle but are cleared when the app is closed. Consider using AsyncStorage or another persistence mechanism if you need to preserve history across app sessions.
The
getPath function is particularly useful for multi-waypoint animations where you need to animate through intermediate screens.Related
- useScreenState - Access current screen state
- useScreenAnimation - Access animation state for transitions
