<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/react-hook-uselocalstorage-x-timbmxp" -->

---
title: React Hook: useLocalStorage | daily.dev
description: A neat custom React Hook that shows how to use local storage in React to store state. You can just use it in any React component and it allows you to write and...
canonical: https://daily.dev/posts/react-hook-uselocalstorage-x-timbmxp
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: React Hook: useLocalStorage | daily.dev
og:description: A neat custom React Hook that shows how to use local storage in React to store state. You can just use it in any React component and it allows you to write and...
og:url: https://daily.dev/posts/react-hook-uselocalstorage-x-timbmxp
og:image: https://api.daily.dev/og/posts/x-timbmxP.png
og:image:alt: React Hook: useLocalStorage
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# React Hook: useLocalStorage

**[Robin Wieruch](https://daily.dev/sources/robinwieruch)** · [@rwieruch](https://daily.dev/rwieruch) · 1 min read · 27 upvotes · 2 comments

## Summary

A neat custom React Hook that shows how to use local storage in React to store state. You can just use it in any React component and it allows you to write and read state. The hook is only there as a learning experience though. If you rely on the local storage for your React application in production, you should check out more widely used hooks.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.robinwieruch.de/react-uselocalstorage-hook/>

## Community discussion

Top comments from developers on daily.dev.

**@pj\_ifrost** · 0 upvotes

> Super useful for junior devs

**@prakash\_choks** · 0 upvotes

> Will suggest this package for big react projects
>  https://www.npmjs.com/package/@webcored/react-local-storage

---

Tags: [#react](https://daily.dev/tags/react), [#storage](https://daily.dev/tags/storage), [#webdev](https://daily.dev/tags/webdev)

[View this post on daily.dev](https://daily.dev/posts/react-hook-uselocalstorage-x-timbmxp)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"React Hook: useLocalStorage","url":"https://daily.dev/posts/react-hook-uselocalstorage-x-timbmxp","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/react-hook-uselocalstorage-x-timbmxp"},"datePublished":"2022-04-05T09:56:42.193Z","dateModified":"2026-10-14T02:14:41.530Z","description":"A neat custom React Hook that shows how to use local storage in React to store state. You can just use it in any React component and it allows you to write and...","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5ed34dfda00ce4b106ba42d32577a365","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/5ed34dfda00ce4b106ba42d32577a365","isAccessibleForFree":true,"articleSection":"Robin Wieruch","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Person","name":"Robin Wieruch","url":"https://daily.dev/rwieruch","image":"https://avatars.githubusercontent.com/u/2479967?v=4","interactionStatistic":{"@type":"InteractionCounter","interactionType":{"@type":"EndorseAction"},"userInteractionCount":1500}},"commentCount":2,"discussionUrl":"https://daily.dev/posts/react-hook-uselocalstorage-x-timbmxp","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":27},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":2}],"keywords":"react,storage,webdev","timeRequired":"PT1M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Robin Wieruch","item":"https://daily.dev/sources/robinwieruch"},{"@type":"ListItem","position":3,"name":"React Hook: useLocalStorage"}]}
{"@context":"https://schema.org","@type":"WebPage","@id":"https://daily.dev/posts/react-hook-uselocalstorage-x-timbmxp","comment":[{"@type":"Comment","text":"Super useful for junior devs","datePublished":"2022-04-05T17:11:42.478Z","url":"https://daily.dev/posts/x-timbmxP#c-j8oUi5ZHQ","author":{"@type":"Person","name":"Patryk","url":"https://daily.dev/pj_ifrost","image":"https://avatars.githubusercontent.com/u/34837954?v=4"}},{"@type":"Comment","text":"Will suggest this package for big react projects\nhttps://www.npmjs.com/package/@webcored/react-local-storage","datePublished":"2022-06-03T05:04:17.779Z","url":"https://daily.dev/posts/x-timbmxP#c-l0LnHmhYD","author":{"@type":"Person","name":"Prakash Chokalingam","url":"https://daily.dev/prakash_choks","image":"https://lh3.googleusercontent.com/a-/AOh14GhLYX6EfX6bHUYRexm2bBzngznqlsBNR4cGrlg-wQ=s100"}}]}
```

