Discord: https://discord.gg/DTJV27BYwA
A lightweight collection of production-ready React hooks and utility functions. Zero dependencies. SSR-safe. StrictMode-friendly.
- Installation
- Features
- Usage
- Example Hooks
- Available Hooks
- Contributing
- Code Style Guidelines
- Roadmap
- License
To install the React Smart Utils library, use npm or yarn:
npm install react-smart-utilsor
yarn add react-smart-utils- Custom Hooks: Reusable React hooks to solve common use cases.
- Utility Functions: Handy utilities to simplify everyday coding tasks.
- TypeScript Support: Fully typed with TypeScript for a smooth developer experience.
- Tree-shakable: Only include what you need, minimizing bundle size.
| Hook | Description | React Native Support | Mobile Alternative / Notes |
|---|---|---|---|
useToggle |
Manage boolean state with helper actions | ✅ Yes | Works out of the box |
usePrevious |
Get previous value of state or prop | ✅ Yes | Works out of the box |
useLocalStorage |
Persist state in localStorage |
❌ No | Use AsyncStorage |
useCountdown |
Countdown timer with controls | ✅ Yes | Works out of the box |
useDebounceValue |
Debounce changing values | ✅ Yes | Works out of the box |
useUpdateEffect |
Effect that skips initial render | ✅ Yes | Works out of the box |
useRunOnlyOnce |
Run logic exactly once (StrictMode safe) | ✅ Yes | Works out of the box |
useUnmount |
Run cleanup logic on unmount | ✅ Yes | Works out of the box |
useIsMounted |
Prevent state updates after unmount | ✅ Yes | Works out of the box |
useClipboard |
Copy text to clipboard | Use expo-clipboard / RN Clipboard |
|
useNetwork |
Track online/offline state | Use @react-native-community/netinfo |
|
useWindowSize |
Track window dimensions | ❌ No | Use useWindowDimensions |
| Utility | Description | React Native Support | Notes |
|---|---|---|---|
clamp |
Clamp a number between min & max | ✅ Yes | Pure function |
hasKey |
Type-safe object key check | ✅ Yes | TS-friendly |
isNull |
Check if value is null |
✅ Yes | Pure function |
isUndefined |
Check if value is undefined |
✅ Yes | Pure function |
sample |
Get random item from array | ✅ Yes | Pure function |
sleep |
Async delay helper | ✅ Yes | Works everywhere |
throttle |
Throttle function execution | ✅ Yes | Platform-agnostic |
toLower |
Convert string to lowercase | ✅ Yes | Safe wrapper |
toUpperCase |
Convert string to uppercase | ✅ Yes | Safe wrapper |
uniqueArray |
Remove duplicate array values | ✅ Yes | Uses Set |
We welcome contributions! Please follow the instructions below to set up the project for development and make your contributions.
- Fork the repositoryon GitHub.
- Clone your forked repository:
git clone https://github.com/your-username/react-smart-utils.git
cd package
yarn install3.Test your functions or hooks in smart-app:
cd smart-app
yarn install
yarn devNote: You can push example code as it helps in preparing documents (When Raise PR you must paste the path in PR description)
4.Create a new branch for your feature:
git checkout -b feature/my-new-feature- Make your changes, then commit and push:
git commit -m "Add new feature"
git push origin feature/my-new-featureSubmit a Pull Request with a detailed explanation of your changes.
