anshin
v0.4.3
Published
anshin (安心) - React hooks that give you peace of mind. Utility hooks for front-end developers that handle the complexity so you can relax.
Downloads
488
Maintainers
Readme
anshin (安心)
Peace of mind for React developers
About
anshin is a React hooks library designed to give you peace of mind. The name comes from the Japanese word 安心 (anshin), which means "peace of mind" - the feeling that nothing needs your attention because things are handled.
✨ Features
- 🎯 21+ Production-Ready Hooks - State, effects, UI, utilities, and network
- 📦 Zero Dependencies - No bloat, just pure React goodness
- 🔒 100% TypeScript - Full type safety and IntelliSense support
- 🌳 Tree-Shakeable - Import only what you need
- ✅ Fully Tested - Comprehensive test coverage
- 📚 Well Documented - Clear examples and API references
🚀 Installation
npm install anshin
# or
yarn add anshin
# or
pnpm add anshin📖 Quick Start
import { useCountdown, useClipboard, useBreakpoint } from 'anshin'
function App() {
// Countdown timer
const { count, start, pause, reset } = useCountdown({
start: 60,
target: 0
})
// Clipboard operations
const { copy, isCopied } = useClipboard()
// Responsive breakpoints
const breakpoint = useBreakpoint()
return (
<div>
<p>Time: {count}s</p>
<p>Screen: {breakpoint}</p>
<button onClick={() => copy('Hello!')}>
{isCopied ? 'Copied!' : 'Copy'}
</button>
</div>
)
}🎣 Available Hooks
State Management
useVisibility- Toggle visibility states with callbacksuseStepper- Multi-step form/wizard state management
Side Effects
useLeavePage- Prevent accidental page navigationuseSpecializedEffect- Lifecycle-specific effects (mount, update, unmount)useSelfUnmount- Component self-unmounting with conditions
UI & Interactions
useBreakpoint- Responsive breakpoint detectionuseClickAway- Detect clicks outside elementsuseMousePosition- Track mouse/pointer positionusePreventScroll- Lock/unlock body scrolluseTabTitle- Dynamic document title management
Utilities
useCountdown- Countdown/count-up timeruseDebounce- Debounce values and callbacksuseClipboard- Copy to clipboard with feedbackuseDelay- Debounced delays and timeoutsuseForceRerender- Force component re-renderuseMultiTab- Detect multiple open tabs
Network & Browser
useGeoLocation- Get user's locationuseFetchWithRetry- Fetch with retry logicuseScript- Dynamic script loadinguseBattery- Battery status monitoringuseDetectIdle- Detect user idlenessuseIncognito- Detect private browsing mode
💡 Philosophy
Every hook in this library embodies a simple promise: "I got you, relax dear developer."
We handle the complexity, edge cases, and boilerplate so you can focus on building great experiences.
🤝 Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-hook) - Commit your changes (
git commit -m 'Add amazing hook') - Push to the branch (
git push origin feature/amazing-hook) - Open a Pull Request
📄 License
MIT © Kim Fajardo
Made with ❤️ by Kim Fajardo
