Cache a MetaMask Wallet Address in localStorage

InstructorRyan Harris

Share this video with your friends

Send Tweet

Since we are storing the user’s wallet address in React state, it is lost when the dApp is reloaded. To fix this, we’ll cache the address in localStorage.

We’ll use the useEffect hook to look for an address in localStorage if there isn’t one in local state.