usehooks-ts
Web framework / library · Free
A collection of typed React hooks for browser APIs and state: it speeds up recurring interface patterns.
Also known as: juliencrn/usehooks-ts; react-hooks-typescript; usehooks

What you can use for free
Code and local use under MIT.
Paid features and costs
Computing resources, self-hosting, and external services are paid for separately if used.
Access and limitations
Code and local use under MIT. Computing resources, self-hosting, and external services are paid for separately if used.
Use cases
- Connect a browser API to a typed React hook
- Connect its result to a component and test changes in the corresponding browser state
Example workflow
A possible workflow; this is not a report of hands-on testing.
Connect a browser API to a typed React hook.
Before you start
- Web application source code and the intended workflow.
- The project's framework and runtime version.
Steps
- Choose a hook for a specific browser API or screen state.
- Connect its result to a component and test changes in the corresponding browser state.
- Add real data and error handling; check the production build.
Check your result
- The workflow works after a page refresh and with invalid data.
- The bundle, server rendering, and supported browsers suit the project.
Choosing usehooks-ts
Connect a browser API to a typed React hook
Choose this when
- Connect a browser API to a typed React hook
- Connect its result to a component and test changes in the corresponding browser state
Requirements
- For SSR, the documentation recommends initializeWithValue: false to return the initial value before reading localStorage.
Things to consider
- Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.
- Terms of use: MIT for the code; dependencies have separate licenses.
- The hook code returns initialValue on read or JSON parsing errors and reports write errors. It does not back up storage or establish data preservation after browser clearing.
Frequently asked questions
What can you use for free in usehooks-ts?
Code and local use under MIT.
What additional costs might arise with usehooks-ts?
Computing resources, self-hosting, and external services are paid for separately if used.
What terms of use matter for usehooks-ts?
MIT for the code; dependencies have separate licenses.
How do you get started with usehooks-ts?
Choose a hook for a specific browser API or screen state. Connect its result to a component and test changes in the corresponding browser state. Add real data and error handling; check the production build.
What does usehooks-ts useLocalStorage return?
The hook returns the stored value, a setter, and a key removal function. It serializes JSON by default; serializer and deserializer can be replaced, and updates are tracked through storage and a local event.
License
MIT for the code; dependencies have separate licenses.
MIT — permissive license
You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.
License termsTechnologies and topics
- usehooks-ts
- web
- Development