From 0f615236a70fa9bd98c2940cac5f0faed26b9804 Mon Sep 17 00:00:00 2001 From: n33pm <12273891+n33pm@users.noreply.github.com> Date: Tue, 5 Aug 2025 09:14:40 +0200 Subject: [PATCH] docs: add useHistory #150 --- docs/api/useHistory.md | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 docs/api/useHistory.md diff --git a/docs/api/useHistory.md b/docs/api/useHistory.md new file mode 100644 index 0000000..47943ab --- /dev/null +++ b/docs/api/useHistory.md @@ -0,0 +1,40 @@ +--- +title: "useHistory" +permalink: /use-history/ +nav_order: 11 +--- + +# `useHistory` + +Get the current browser history state and scroll restoration setting. This hook provides access to the browser's history API state and scroll restoration behavior, updating automatically when the location changes. + +## API + +```typescript +export function useHistory(): RavigerHistory + +interface RavigerHistory { + scrollRestoration: 'auto' | 'manual' + state: unknown +} +``` + +## Properties + +- **`scrollRestoration`**: The current scroll restoration mode ('auto' or 'manual') +- **`state`**: The current history state object, or `null` if no state is set + +## Example + +```typescript +import { useHistory } from 'raviger' + +function MyComponent() { + const history = useHistory() + + console.log('Scroll restoration:', history.scrollRestoration) + console.log('History state:', history.state) + + return