[DX] Implement Custom Network Connection Quality Detection Hook
Maintainers usually reply within 1 day
Nobody has claimed this yet.
- #409 by @kanaksahu111 — closed without merging
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 85/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- next.js, react, typescript
- Domain
- developer-experience, frontend
Research direction
Add the hook in src/hooks/use-network-quality.ts using navigator.connection when present and falling back to navigator.onLine, returning { isOnline, effectiveType, saveData, isSlowConnection } and updating on connection change plus window online/offline. Mark isSlowConnection true for 2g, slow-2g, or saveData. Cover online/offline and mocked connection types in tests/use-network-quality.test.ts with Vitest; done when the hook matches the stated shape and those tests pass.
Written by the indexing model from the issue text.
Description
🎯 Goal
Implement a custom React hook in src/hooks/use-network-quality.ts to detect connection speed and data saver settings for optimizing background polling and asset loading.
📋 Feature Details & Requirements
- Hook File:
src/hooks/use-network-quality.ts - Core Functionality:
- Monitor
navigator.connection(Network Information API) if available, fallback tonavigator.onLine. - Return state:
{ isOnline: boolean, effectiveType: '4g' | '3g' | '2g' | 'slow-2g' | 'unknown', saveData: boolean, isSlowConnection: boolean }. - Mark
isSlowConnectionastrueifeffectiveTypeis2gorslow-2gor ifsaveDatais enabled. - Listen to connection
changeevents and windowonline/offlineevents to update state dynamically.
- Monitor
🧪 Unit Testing Requirements
- Create unit tests in
tests/use-network-quality.test.tsusing Vitest. - Test hook behavior with online/offline toggles and mock network connection types.
- Dominant language
- TypeScript
- Stars
- 5
- Forks
- 7
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 79
Getting set up
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from TheVicky1/Pact_OS
-
area:finance difficulty:easy enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
[Text] Add Word-Boundary Preserving Smart Text Truncator in src/lib/text/smart-truncate.tsPossibly taken @rudraparmar76 claimed this today. Openarea:data difficulty:easy enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
TheVicky1/Pact_OS#760 · 1 comment ·
Maintainers usually reply within 1 day
-
area:habits difficulty:easy enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 1 day
-
area:analytics difficulty:easy enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day
-
area:data beginner-friendly difficulty:easy enhancement good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
All issues in TheVicky1/Pact_OS
Similar issues
-
Waiting for: Product Owner
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
getsentry/sentry-javascript#26203 · 1 comment ·
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
bytedance/flowgram.ai#1235 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
devswha/herdr-web-ui#3325 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100