Document Title Sync with State + Restore on Unmount
Keep the browser tab title in sync with component state (e.g., unread count) and safely restore the previous title w...
<script setup lang="ts">
import { ref, watch, onMounted, onBeforeUnmount } from 'vue';
// Example state that influences the tab title
const unreadCount = ref<number>(3);
const baseTitle = 'Inbox';
// Store the title that existed before this component mounted