useState — SSR-compatible state. ref — client-only state.
useState:
1<script setup>2// Shared between server and client3const count = useState("count", () => 0)45// Increment6count.value++7</script>
ref:
1<script setup>2// Client-only3const count = ref(0)4</script>
Key differences: