Hooks
React hooks for documentation features
Custom hooks for common documentation patterns.
UseCopy
Copy text to clipboard with feedback state.
| prop | type |
|---|---|
duration? | number |
UseCopy returns
| prop | type |
|---|---|
copied? | boolean |
copy? | (text: string) => Promise<void> |
UseToc
Access table of contents state for custom toc implementations.
UseToc returns
| prop | type |
|---|---|
headings? | Heading[] |
active? | string |
Heading type
UseKeyboardNav
Enable keyboard navigation between documentation pages.
This hook enables:
- left arrow - navigate to previous page
- right arrow - navigate to next page
| prop | type |
|---|---|
docs | DocMeta[] |
basePath? | string |
UseScrollSpy
Track which heading is currently visible in the viewport.
| prop | type |
|---|---|
ids | string[] |
offset? | number |
threshold? | number |
UseAnchorScroll
Smooth scrolling to anchor links with configurable offset.
| prop | type |
|---|---|
offset? | number |
smooth? | boolean |
UseMediaQuery
React to media query changes.
Available hooks:
useMediaQuery(query)- custom media queryuseIsMobile()- below 768pxuseIsTablet()- 769px to 1024pxuseIsDesktop()- above 1025pxusePrefersDark()- dark mode preferenceusePrefersReducedMotion()- reduced motion preference
UseLocalStorage
Persist state to local storage.
| prop | type |
|---|---|
key | string |
defaultValue | T |
Also available: useSessionStorage with same API.
UseToast
Show toast notifications with configurable types and duration.
UseToast returns
| prop | type |
|---|---|
toasts? | Toast[] |
add? | (toast: Omit<Toast, 'id'>) => void |
remove? | (id: string) => void |
Toast type
UseDebounce
Debounce a value with configurable delay.
| prop | type |
|---|---|
value | T |
delay | number |