---
title: "Discussion on \"React usePersistedState hook\" | Hashnode"
description: "Discussion on \"React usePersistedState hook\". Returns a stateful value, persisted in localStorage, and a function to update it.\n\nUse the useState() hook to initialize the value to defaultValue .\nUse the useRef() hook to create a ref that will hold the name of the value in Window.localStorage. \nU..."
url: "https://hashnode.com/posts/react-usepersistedstate-hook/626d6ac4a2d355d4df43f1b4"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [React usePersistedState hook](https://walidcherhane.hashnode.dev/react-usepersistedstate-hook?utm_source=hashnode&utm_medium=feed)

Returns a stateful value, persisted in localStorage, and a function to update it. Use the useState() hook to initialize the value to defaultValue . Use the useRef() hook to create a ref that will hold the name of the value in Window.localStorage. U...

Apr 30, 2022 · 2 min read · walidcherhane.hashnode.dev  
Read the article

-   [#react-hook-1](https://hashnode.com/tag/react-hook-1)
-   [#hooks](https://hashnode.com/tag/hooks)
-   [#reactjs](https://hashnode.com/tag/reactjs)
-   [#localstorage](https://hashnode.com/tag/localstorage)
-   [#javascript](https://hashnode.com/tag/javascript)

## Written by

[Walid Cherhane](https://hashnode.com/@Walidcherhane)

@Walidcherhane · Morocco

  
[View profile](https://hashnode.com/@Walidcherhane)

Front-end dev

I do the coding stuff... mostly with ReactJs

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
