react-hooks-core 1.0.2 β 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +245 -245
- package/dist/chunk-3OHPGV6V.mjs +292 -0
- package/dist/chunk-3OHPGV6V.mjs.map +1 -0
- package/dist/chunk-3QXSUE3X.js +294 -0
- package/dist/chunk-3QXSUE3X.js.map +1 -0
- package/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +5 -0
- package/dist/index.mjs +1 -0
- package/dist/storage/index.d.mts +26 -0
- package/dist/storage/index.d.ts +26 -0
- package/dist/storage/index.js +12 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/index.mjs +3 -0
- package/dist/storage/index.mjs.map +1 -0
- package/package.json +96 -91
package/README.md
CHANGED
|
@@ -1,245 +1,245 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
<h1>β‘ React Hooks Core</h1>
|
|
3
|
-
<p><strong>Production-ready React hooks that solve real-world problems</strong></p>
|
|
4
|
-
|
|
5
|
-
[](https://www.npmjs.com/package/react-hooks-core)
|
|
6
|
-
[](https://github.com/NightDevilPT/react-hooks-core/blob/main/LICENSE)
|
|
7
|
-
[](https://www.typescriptlang.org/)
|
|
8
|
-
[](https://github.com/NightDevilPT/react-hooks-core)
|
|
9
|
-
</div>
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## π― What is React Hooks Core?
|
|
14
|
-
|
|
15
|
-
**React Hooks Core** is a comprehensive collection of production-ready React hooks designed to solve common problems you face when building modern React and Next.js applications. Instead of reinventing the wheel for every project, React Hooks Core provides battle-tested, well-documented hooks that work out of the box.
|
|
16
|
-
|
|
17
|
-
Whether you're building a SaaS platform, e-commerce site, dashboard, or any production application, React Hooks Core helps you ship faster with fewer bugs and better user experiences.
|
|
18
|
-
|
|
19
|
-
---
|
|
20
|
-
|
|
21
|
-
## πΌ Built for Production
|
|
22
|
-
|
|
23
|
-
### Why Production Projects Need React Hooks Core
|
|
24
|
-
|
|
25
|
-
Every production React application faces the same challenges:
|
|
26
|
-
|
|
27
|
-
- **Device Detection** - Need to know if users are on mobile, tablet, or desktop to optimize layouts and features
|
|
28
|
-
- **Network Monitoring** - Handle offline scenarios gracefully, show connection status, sync data when back online
|
|
29
|
-
- **User Activity Tracking** - Implement auto-logout for security, pause expensive operations when idle
|
|
30
|
-
- **Responsive Design** - Build adaptive UIs that respond to viewport changes and system preferences
|
|
31
|
-
- **Performance Optimization** - Adapt content quality based on network speed, battery level, and device capabilities
|
|
32
|
-
|
|
33
|
-
**React Hooks Core solves these problems** with hooks that are:
|
|
34
|
-
- β
**SSR-Compatible** - Works seamlessly with Next.js App Router and Pages Router
|
|
35
|
-
- β
**Type-Safe** - Full TypeScript support with proper generics and inference
|
|
36
|
-
- β
**Well-Tested** - Comprehensive test coverage ensuring reliability
|
|
37
|
-
- β
**Production-Ready** - Used in real-world applications, not just demos
|
|
38
|
-
- β
**Zero Dependencies** - Lightweight and performant
|
|
39
|
-
- β
**Tree-Shakeable** - Import only what you need, keep bundle sizes minimal
|
|
40
|
-
|
|
41
|
-
---
|
|
42
|
-
|
|
43
|
-
## π How React Hooks Core Helps Your Production Projects
|
|
44
|
-
|
|
45
|
-
### β‘ Faster Development
|
|
46
|
-
|
|
47
|
-
Stop rewriting the same logic for every project. React Hooks Core provides ready-to-use hooks that handle edge cases, error scenarios, and browser compatibility issues you might miss. Focus on building features, not infrastructure.
|
|
48
|
-
|
|
49
|
-
### π Fewer Bugs
|
|
50
|
-
|
|
51
|
-
Every hook in React Hooks Core is thoroughly tested with comprehensive test suites covering initialization, SSR compatibility, state updates, error handling, cleanup, and edge cases. This means fewer bugs in production and more confidence in your code.
|
|
52
|
-
|
|
53
|
-
### π¦ Optimized Bundle Size
|
|
54
|
-
|
|
55
|
-
Tree-shakeable imports mean you only bundle what you use. Zero dependencies keep your bundle size minimal. Perfect for production applications where every kilobyte matters.
|
|
56
|
-
|
|
57
|
-
### π― Better User Experience
|
|
58
|
-
|
|
59
|
-
React Hooks Core hooks respect user preferences and device capabilities. Detect system dark mode, respect reduced motion preferences, adapt to network conditions, and optimize for battery life. Your users will notice the difference.
|
|
60
|
-
|
|
61
|
-
### π Enhanced Security
|
|
62
|
-
|
|
63
|
-
Built-in features like idle detection help you implement security best practices like auto-logout, session management, and activity monitoring without additional complexity.
|
|
64
|
-
|
|
65
|
-
### π Universal Compatibility
|
|
66
|
-
|
|
67
|
-
Works with React 18+ and Next.js 13+ (both App Router and Pages Router). SSR-compatible out of the box, so you don't have to worry about hydration mismatches or server-side rendering issues.
|
|
68
|
-
|
|
69
|
-
---
|
|
70
|
-
|
|
71
|
-
## β¨ Key Features
|
|
72
|
-
|
|
73
|
-
- β
**TypeScript First** - Full type safety with generics and proper inference
|
|
74
|
-
- β
**SSR Compatible** - Works seamlessly with Next.js 13+ (App Router & Pages Router)
|
|
75
|
-
- β
**Tree-Shakeable** - Import only what you need, keep bundle sizes minimal
|
|
76
|
-
- β
**Zero Dependencies** - Lightweight and performant
|
|
77
|
-
- β
**Well Tested** - 92+ tests with comprehensive coverage on critical hooks
|
|
78
|
-
- β
**Production Ready** - Used in real-world applications
|
|
79
|
-
- β
**Accessibility First** - Respects user preferences (reduced motion, contrast, etc.)
|
|
80
|
-
- β
**Error Resilient** - Graceful fallbacks and comprehensive error handling
|
|
81
|
-
- β
**Performance Optimized** - Minimal re-renders and efficient event handling
|
|
82
|
-
|
|
83
|
-
---
|
|
84
|
-
|
|
85
|
-
## π¦ Installation
|
|
86
|
-
|
|
87
|
-
```bash
|
|
88
|
-
npm install react-hooks-core
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
```bash
|
|
92
|
-
yarn add react-hooks-core
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
```bash
|
|
96
|
-
pnpm add react-hooks-core
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
---
|
|
100
|
-
|
|
101
|
-
## π Quick Start
|
|
102
|
-
|
|
103
|
-
All hooks work out of the box with zero configuration. Simply import what you need:
|
|
104
|
-
|
|
105
|
-
```tsx
|
|
106
|
-
import { useDeviceDetect, useOnline, useIdle, useMediaQuery } from 'react-hooks-core'
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
Tree-shakeable imports mean you only bundle what you use, keeping your production bundle size minimal.
|
|
110
|
-
|
|
111
|
-
---
|
|
112
|
-
|
|
113
|
-
## π Available Hooks
|
|
114
|
-
|
|
115
|
-
React Hooks Core provides hooks across multiple categories to help you build production-ready applications:
|
|
116
|
-
|
|
117
|
-
### π Browser & Device Hooks
|
|
118
|
-
|
|
119
|
-
Monitor device capabilities, network status, user activity, and system preferences to build adaptive, responsive applications.
|
|
120
|
-
|
|
121
|
-
- **[Device Detection](src/browser/docs/useDeviceDetect.md)** - Detect device type, operating system, and browser environment
|
|
122
|
-
- **[Network Monitoring](src/browser/docs/useOnline.md)** - Real-time online/offline status and connection quality
|
|
123
|
-
- **[User Activity](src/browser/docs/useIdle.md)** - Track user inactivity for security and performance optimization
|
|
124
|
-
- **[Media Queries](src/browser/docs/useMediaQuery.md)** - Listen to CSS media queries in JavaScript for responsive logic
|
|
125
|
-
- **[Network Speed](src/browser/docs/useNetworkSpeed.md)** - Adapt content quality based on connection speed
|
|
126
|
-
- **[Battery Status](src/browser/docs/useBattery.md)** - Optimize features based on device battery level
|
|
127
|
-
- **[Geolocation](src/browser/docs/useGeolocation.md)** - Access user location with proper permission handling
|
|
128
|
-
|
|
129
|
-
For detailed documentation on each hook, visit the [documentation folder](src/browser/docs) or check the individual hook files linked above.
|
|
130
|
-
|
|
131
|
-
---
|
|
132
|
-
|
|
133
|
-
## π¨ Live Demo
|
|
134
|
-
|
|
135
|
-
An interactive demo showcasing all hooks is available in the `next-example` folder. See React Hooks Core in action with real-time updates and visual indicators.
|
|
136
|
-
|
|
137
|
-
Run locally: `npm run build && npm link && cd next-example && npm link react-hooks-core && npm run dev`
|
|
138
|
-
|
|
139
|
-
---
|
|
140
|
-
|
|
141
|
-
## π Why Choose React Hooks Core for Production?
|
|
142
|
-
|
|
143
|
-
### Problem: Reinventing the Wheel
|
|
144
|
-
|
|
145
|
-
Every React project needs device detection, online status monitoring, responsive design logic, and user activity tracking. Developers waste countless hours implementing these features from scratch, often with bugs, edge cases, and compatibility issues.
|
|
146
|
-
|
|
147
|
-
### Solution: Production-Ready Hooks
|
|
148
|
-
|
|
149
|
-
React Hooks Core provides battle-tested hooks that:
|
|
150
|
-
- β
Work out of the box with React 18+ and Next.js 13+
|
|
151
|
-
- β
Handle SSR/CSR seamlessly without configuration
|
|
152
|
-
- β
Include proper TypeScript types with full inference
|
|
153
|
-
- β
Cover edge cases you might miss
|
|
154
|
-
- β
Are fully tested with 92+ test cases
|
|
155
|
-
- β
Follow React best practices and patterns
|
|
156
|
-
- β
Have zero dependencies
|
|
157
|
-
- β
Are optimized for performance
|
|
158
|
-
|
|
159
|
-
### Impact on Your Development
|
|
160
|
-
|
|
161
|
-
- β‘ **Faster Development** - Stop rewriting the same logic, ship features faster
|
|
162
|
-
- π **Fewer Bugs** - Tested hooks mean fewer edge cases and production issues
|
|
163
|
-
- π¦ **Smaller Bundle** - Tree-shakeable and zero dependencies keep bundles minimal
|
|
164
|
-
- π― **Better UX** - Respect user preferences and device capabilities automatically
|
|
165
|
-
- π **More Secure** - Built-in security features like idle detection for auto-logout
|
|
166
|
-
- π° **Cost Effective** - Reduce development time and maintenance overhead
|
|
167
|
-
|
|
168
|
-
---
|
|
169
|
-
|
|
170
|
-
## πΊοΈ Roadmap
|
|
171
|
-
|
|
172
|
-
We're actively expanding React Hooks Core with more production-ready hooks across multiple categories:
|
|
173
|
-
|
|
174
|
-
### π Coming Soon
|
|
175
|
-
|
|
176
|
-
- **Timer & Interval Hooks** - `useInterval`, `useTimeout`, `useCountdown`, `useDebounce`, `useThrottle`
|
|
177
|
-
- **UI & DOM Hooks** - `useClickOutside`, `useElementSize`, `useWindowSize`, `useScrollPosition`, `useHover`
|
|
178
|
-
- **Storage Hooks** - `
|
|
179
|
-
- **Context & Providers** - Global state management and configuration providers
|
|
180
|
-
|
|
181
|
-
### π― Our Commitment
|
|
182
|
-
|
|
183
|
-
- β
**Production-ready only** - Every hook is battle-tested before release
|
|
184
|
-
- β
**SSR-first** - Works with Next.js out of the box
|
|
185
|
-
- β
**100% test coverage** - Critical hooks are fully tested
|
|
186
|
-
- β
**TypeScript-native** - Proper types, not afterthoughts
|
|
187
|
-
- β
**Zero breaking changes** - Semantic versioning strictly followed
|
|
188
|
-
|
|
189
|
-
---
|
|
190
|
-
|
|
191
|
-
## π οΈ Development & Testing
|
|
192
|
-
|
|
193
|
-
### Local Development
|
|
194
|
-
|
|
195
|
-
Use `npm link` to test the package in your projects before publishing. Build the package, link it globally, then link it in your project for instant testing.
|
|
196
|
-
|
|
197
|
-
### Testing Suite
|
|
198
|
-
|
|
199
|
-
Comprehensive test coverage with 92+ test cases covering initialization, SSR compatibility, state updates, error handling, cleanup, options, edge cases, and TypeScript types.
|
|
200
|
-
|
|
201
|
-
### Build System
|
|
202
|
-
|
|
203
|
-
Fast builds with `tsup` supporting both CommonJS and ES modules, TypeScript declarations, source maps, and tree-shaking optimization.
|
|
204
|
-
|
|
205
|
-
---
|
|
206
|
-
|
|
207
|
-
## π€ Contributing
|
|
208
|
-
|
|
209
|
-
We welcome contributions from the community! Whether it's bug fixes, new hooks, documentation improvements, or feature suggestions, your input helps make React Hooks Core better for everyone.
|
|
210
|
-
|
|
211
|
-
Please see our [Contributing Guide](CONTRIBUTING.md) for guidelines on code style, testing requirements, and the pull request process.
|
|
212
|
-
|
|
213
|
-
---
|
|
214
|
-
|
|
215
|
-
## π License
|
|
216
|
-
|
|
217
|
-
MIT License - see [LICENSE](LICENSE) file for details
|
|
218
|
-
|
|
219
|
-
Copyright (c) 2025 React Hooks Core
|
|
220
|
-
|
|
221
|
-
---
|
|
222
|
-
|
|
223
|
-
## π Links
|
|
224
|
-
|
|
225
|
-
- [NPM Package](https://www.npmjs.com/package/react-hooks-core)
|
|
226
|
-
- [GitHub Repository](https://github.com/NightDevilPT/react-hooks-core)
|
|
227
|
-
- [Issue Tracker](https://github.com/NightDevilPT/react-hooks-core/issues)
|
|
228
|
-
- [Changelog](CHANGELOG.md)
|
|
229
|
-
|
|
230
|
-
---
|
|
231
|
-
|
|
232
|
-
## π¬ Support
|
|
233
|
-
|
|
234
|
-
- π [Report a bug](https://github.com/NightDevilPT/react-hooks-core/issues/new?template=bug_report.md)
|
|
235
|
-
- β¨ [Request a feature](https://github.com/NightDevilPT/react-hooks-core/issues/new?template=feature_request.md)
|
|
236
|
-
- π‘ [Ask a question](https://github.com/NightDevilPT/react-hooks-core/discussions)
|
|
237
|
-
|
|
238
|
-
---
|
|
239
|
-
|
|
240
|
-
<div align="center">
|
|
241
|
-
<p>Made with β€οΈ by developers, for developers</p>
|
|
242
|
-
<p>
|
|
243
|
-
<a href="https://github.com/NightDevilPT/react-hooks-core">β Star us on GitHub</a>
|
|
244
|
-
</p>
|
|
245
|
-
</div>
|
|
1
|
+
<div align="center">
|
|
2
|
+
<h1>β‘ React Hooks Core</h1>
|
|
3
|
+
<p><strong>Production-ready React hooks that solve real-world problems</strong></p>
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/react-hooks-core)
|
|
6
|
+
[](https://github.com/NightDevilPT/react-hooks-core/blob/main/LICENSE)
|
|
7
|
+
[](https://www.typescriptlang.org/)
|
|
8
|
+
[](https://github.com/NightDevilPT/react-hooks-core)
|
|
9
|
+
</div>
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## π― What is React Hooks Core?
|
|
14
|
+
|
|
15
|
+
**React Hooks Core** is a comprehensive collection of production-ready React hooks designed to solve common problems you face when building modern React and Next.js applications. Instead of reinventing the wheel for every project, React Hooks Core provides battle-tested, well-documented hooks that work out of the box.
|
|
16
|
+
|
|
17
|
+
Whether you're building a SaaS platform, e-commerce site, dashboard, or any production application, React Hooks Core helps you ship faster with fewer bugs and better user experiences.
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## πΌ Built for Production
|
|
22
|
+
|
|
23
|
+
### Why Production Projects Need React Hooks Core
|
|
24
|
+
|
|
25
|
+
Every production React application faces the same challenges:
|
|
26
|
+
|
|
27
|
+
- **Device Detection** - Need to know if users are on mobile, tablet, or desktop to optimize layouts and features
|
|
28
|
+
- **Network Monitoring** - Handle offline scenarios gracefully, show connection status, sync data when back online
|
|
29
|
+
- **User Activity Tracking** - Implement auto-logout for security, pause expensive operations when idle
|
|
30
|
+
- **Responsive Design** - Build adaptive UIs that respond to viewport changes and system preferences
|
|
31
|
+
- **Performance Optimization** - Adapt content quality based on network speed, battery level, and device capabilities
|
|
32
|
+
|
|
33
|
+
**React Hooks Core solves these problems** with hooks that are:
|
|
34
|
+
- β
**SSR-Compatible** - Works seamlessly with Next.js App Router and Pages Router
|
|
35
|
+
- β
**Type-Safe** - Full TypeScript support with proper generics and inference
|
|
36
|
+
- β
**Well-Tested** - Comprehensive test coverage ensuring reliability
|
|
37
|
+
- β
**Production-Ready** - Used in real-world applications, not just demos
|
|
38
|
+
- β
**Zero Dependencies** - Lightweight and performant
|
|
39
|
+
- β
**Tree-Shakeable** - Import only what you need, keep bundle sizes minimal
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## π How React Hooks Core Helps Your Production Projects
|
|
44
|
+
|
|
45
|
+
### β‘ Faster Development
|
|
46
|
+
|
|
47
|
+
Stop rewriting the same logic for every project. React Hooks Core provides ready-to-use hooks that handle edge cases, error scenarios, and browser compatibility issues you might miss. Focus on building features, not infrastructure.
|
|
48
|
+
|
|
49
|
+
### π Fewer Bugs
|
|
50
|
+
|
|
51
|
+
Every hook in React Hooks Core is thoroughly tested with comprehensive test suites covering initialization, SSR compatibility, state updates, error handling, cleanup, and edge cases. This means fewer bugs in production and more confidence in your code.
|
|
52
|
+
|
|
53
|
+
### π¦ Optimized Bundle Size
|
|
54
|
+
|
|
55
|
+
Tree-shakeable imports mean you only bundle what you use. Zero dependencies keep your bundle size minimal. Perfect for production applications where every kilobyte matters.
|
|
56
|
+
|
|
57
|
+
### π― Better User Experience
|
|
58
|
+
|
|
59
|
+
React Hooks Core hooks respect user preferences and device capabilities. Detect system dark mode, respect reduced motion preferences, adapt to network conditions, and optimize for battery life. Your users will notice the difference.
|
|
60
|
+
|
|
61
|
+
### π Enhanced Security
|
|
62
|
+
|
|
63
|
+
Built-in features like idle detection help you implement security best practices like auto-logout, session management, and activity monitoring without additional complexity.
|
|
64
|
+
|
|
65
|
+
### π Universal Compatibility
|
|
66
|
+
|
|
67
|
+
Works with React 18+ and Next.js 13+ (both App Router and Pages Router). SSR-compatible out of the box, so you don't have to worry about hydration mismatches or server-side rendering issues.
|
|
68
|
+
|
|
69
|
+
---
|
|
70
|
+
|
|
71
|
+
## β¨ Key Features
|
|
72
|
+
|
|
73
|
+
- β
**TypeScript First** - Full type safety with generics and proper inference
|
|
74
|
+
- β
**SSR Compatible** - Works seamlessly with Next.js 13+ (App Router & Pages Router)
|
|
75
|
+
- β
**Tree-Shakeable** - Import only what you need, keep bundle sizes minimal
|
|
76
|
+
- β
**Zero Dependencies** - Lightweight and performant
|
|
77
|
+
- β
**Well Tested** - 92+ tests with comprehensive coverage on critical hooks
|
|
78
|
+
- β
**Production Ready** - Used in real-world applications
|
|
79
|
+
- β
**Accessibility First** - Respects user preferences (reduced motion, contrast, etc.)
|
|
80
|
+
- β
**Error Resilient** - Graceful fallbacks and comprehensive error handling
|
|
81
|
+
- β
**Performance Optimized** - Minimal re-renders and efficient event handling
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## π¦ Installation
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
npm install react-hooks-core
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
yarn add react-hooks-core
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
```bash
|
|
96
|
+
pnpm add react-hooks-core
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
---
|
|
100
|
+
|
|
101
|
+
## π Quick Start
|
|
102
|
+
|
|
103
|
+
All hooks work out of the box with zero configuration. Simply import what you need:
|
|
104
|
+
|
|
105
|
+
```tsx
|
|
106
|
+
import { useDeviceDetect, useOnline, useIdle, useMediaQuery } from 'react-hooks-core'
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
Tree-shakeable imports mean you only bundle what you use, keeping your production bundle size minimal.
|
|
110
|
+
|
|
111
|
+
---
|
|
112
|
+
|
|
113
|
+
## π Available Hooks
|
|
114
|
+
|
|
115
|
+
React Hooks Core provides hooks across multiple categories to help you build production-ready applications:
|
|
116
|
+
|
|
117
|
+
### π Browser & Device Hooks
|
|
118
|
+
|
|
119
|
+
Monitor device capabilities, network status, user activity, and system preferences to build adaptive, responsive applications.
|
|
120
|
+
|
|
121
|
+
- **[Device Detection](src/browser/docs/useDeviceDetect.md)** - Detect device type, operating system, and browser environment
|
|
122
|
+
- **[Network Monitoring](src/browser/docs/useOnline.md)** - Real-time online/offline status and connection quality
|
|
123
|
+
- **[User Activity](src/browser/docs/useIdle.md)** - Track user inactivity for security and performance optimization
|
|
124
|
+
- **[Media Queries](src/browser/docs/useMediaQuery.md)** - Listen to CSS media queries in JavaScript for responsive logic
|
|
125
|
+
- **[Network Speed](src/browser/docs/useNetworkSpeed.md)** - Adapt content quality based on connection speed
|
|
126
|
+
- **[Battery Status](src/browser/docs/useBattery.md)** - Optimize features based on device battery level
|
|
127
|
+
- **[Geolocation](src/browser/docs/useGeolocation.md)** - Access user location with proper permission handling
|
|
128
|
+
|
|
129
|
+
For detailed documentation on each hook, visit the [documentation folder](src/browser/docs) or check the individual hook files linked above.
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
133
|
+
## π¨ Live Demo
|
|
134
|
+
|
|
135
|
+
An interactive demo showcasing all hooks is available in the `next-example` folder. See React Hooks Core in action with real-time updates and visual indicators.
|
|
136
|
+
|
|
137
|
+
Run locally: `npm run build && npm link && cd next-example && npm link react-hooks-core && npm run dev`
|
|
138
|
+
|
|
139
|
+
---
|
|
140
|
+
|
|
141
|
+
## π Why Choose React Hooks Core for Production?
|
|
142
|
+
|
|
143
|
+
### Problem: Reinventing the Wheel
|
|
144
|
+
|
|
145
|
+
Every React project needs device detection, online status monitoring, responsive design logic, and user activity tracking. Developers waste countless hours implementing these features from scratch, often with bugs, edge cases, and compatibility issues.
|
|
146
|
+
|
|
147
|
+
### Solution: Production-Ready Hooks
|
|
148
|
+
|
|
149
|
+
React Hooks Core provides battle-tested hooks that:
|
|
150
|
+
- β
Work out of the box with React 18+ and Next.js 13+
|
|
151
|
+
- β
Handle SSR/CSR seamlessly without configuration
|
|
152
|
+
- β
Include proper TypeScript types with full inference
|
|
153
|
+
- β
Cover edge cases you might miss
|
|
154
|
+
- β
Are fully tested with 92+ test cases
|
|
155
|
+
- β
Follow React best practices and patterns
|
|
156
|
+
- β
Have zero dependencies
|
|
157
|
+
- β
Are optimized for performance
|
|
158
|
+
|
|
159
|
+
### Impact on Your Development
|
|
160
|
+
|
|
161
|
+
- β‘ **Faster Development** - Stop rewriting the same logic, ship features faster
|
|
162
|
+
- π **Fewer Bugs** - Tested hooks mean fewer edge cases and production issues
|
|
163
|
+
- π¦ **Smaller Bundle** - Tree-shakeable and zero dependencies keep bundles minimal
|
|
164
|
+
- π― **Better UX** - Respect user preferences and device capabilities automatically
|
|
165
|
+
- π **More Secure** - Built-in security features like idle detection for auto-logout
|
|
166
|
+
- π° **Cost Effective** - Reduce development time and maintenance overhead
|
|
167
|
+
|
|
168
|
+
---
|
|
169
|
+
|
|
170
|
+
## πΊοΈ Roadmap
|
|
171
|
+
|
|
172
|
+
We're actively expanding React Hooks Core with more production-ready hooks across multiple categories:
|
|
173
|
+
|
|
174
|
+
### π Coming Soon
|
|
175
|
+
|
|
176
|
+
- **Timer & Interval Hooks** - `useInterval`, `useTimeout`, `useCountdown`, `useDebounce`, `useThrottle`
|
|
177
|
+
- **UI & DOM Hooks** - `useClickOutside`, `useElementSize`, `useWindowSize`, `useScrollPosition`, `useHover`
|
|
178
|
+
- **Storage Hooks** - `useStorage`
|
|
179
|
+
- **Context & Providers** - Global state management and configuration providers
|
|
180
|
+
|
|
181
|
+
### π― Our Commitment
|
|
182
|
+
|
|
183
|
+
- β
**Production-ready only** - Every hook is battle-tested before release
|
|
184
|
+
- β
**SSR-first** - Works with Next.js out of the box
|
|
185
|
+
- β
**100% test coverage** - Critical hooks are fully tested
|
|
186
|
+
- β
**TypeScript-native** - Proper types, not afterthoughts
|
|
187
|
+
- β
**Zero breaking changes** - Semantic versioning strictly followed
|
|
188
|
+
|
|
189
|
+
---
|
|
190
|
+
|
|
191
|
+
## π οΈ Development & Testing
|
|
192
|
+
|
|
193
|
+
### Local Development
|
|
194
|
+
|
|
195
|
+
Use `npm link` to test the package in your projects before publishing. Build the package, link it globally, then link it in your project for instant testing.
|
|
196
|
+
|
|
197
|
+
### Testing Suite
|
|
198
|
+
|
|
199
|
+
Comprehensive test coverage with 92+ test cases covering initialization, SSR compatibility, state updates, error handling, cleanup, options, edge cases, and TypeScript types.
|
|
200
|
+
|
|
201
|
+
### Build System
|
|
202
|
+
|
|
203
|
+
Fast builds with `tsup` supporting both CommonJS and ES modules, TypeScript declarations, source maps, and tree-shaking optimization.
|
|
204
|
+
|
|
205
|
+
---
|
|
206
|
+
|
|
207
|
+
## π€ Contributing
|
|
208
|
+
|
|
209
|
+
We welcome contributions from the community! Whether it's bug fixes, new hooks, documentation improvements, or feature suggestions, your input helps make React Hooks Core better for everyone.
|
|
210
|
+
|
|
211
|
+
Please see our [Contributing Guide](CONTRIBUTING.md) for guidelines on code style, testing requirements, and the pull request process.
|
|
212
|
+
|
|
213
|
+
---
|
|
214
|
+
|
|
215
|
+
## π License
|
|
216
|
+
|
|
217
|
+
MIT License - see [LICENSE](LICENSE) file for details
|
|
218
|
+
|
|
219
|
+
Copyright (c) 2025 React Hooks Core
|
|
220
|
+
|
|
221
|
+
---
|
|
222
|
+
|
|
223
|
+
## π Links
|
|
224
|
+
|
|
225
|
+
- [NPM Package](https://www.npmjs.com/package/react-hooks-core)
|
|
226
|
+
- [GitHub Repository](https://github.com/NightDevilPT/react-hooks-core)
|
|
227
|
+
- [Issue Tracker](https://github.com/NightDevilPT/react-hooks-core/issues)
|
|
228
|
+
- [Changelog](CHANGELOG.md)
|
|
229
|
+
|
|
230
|
+
---
|
|
231
|
+
|
|
232
|
+
## π¬ Support
|
|
233
|
+
|
|
234
|
+
- π [Report a bug](https://github.com/NightDevilPT/react-hooks-core/issues/new?template=bug_report.md)
|
|
235
|
+
- β¨ [Request a feature](https://github.com/NightDevilPT/react-hooks-core/issues/new?template=feature_request.md)
|
|
236
|
+
- π‘ [Ask a question](https://github.com/NightDevilPT/react-hooks-core/discussions)
|
|
237
|
+
|
|
238
|
+
---
|
|
239
|
+
|
|
240
|
+
<div align="center">
|
|
241
|
+
<p>Made with β€οΈ by developers, for developers</p>
|
|
242
|
+
<p>
|
|
243
|
+
<a href="https://github.com/NightDevilPT/react-hooks-core">β Star us on GitHub</a>
|
|
244
|
+
</p>
|
|
245
|
+
</div>
|