function Counter() {
const [count, setCount] = useState(0);
useEffect(() => {
document.title = `Count: ${count}`;
}, [count]);
return (
<button onClick={() => setCount((c) => c + 1)}>
+1 ({count})
</button>
);
}
Basic state + effect hook syncing the document title.