Next.js
beginner
15 min
useState
Learn about useState in Next.js.
useState
useState is a React Hook that lets you add state to functional components. It returns the current state value and a function to update it.
Example
const [count, setCount] = useState(0);
function increment() {
setCount(count + 1);
}Practice
Build a like button. Clicking it toggles the like state and updates the count.