Check if a user has previously logged in getItem(“user”); if (loggedInUser) { const foundUser = JSON. parse(loggedInUser); setUser(foundUser); } }, []); Remember to use an empty dependency array in your useEffect hook so that it checks if there’s a logged in user the first time the app loads.