This has been introduced in Vue version 3.5
https://vuejs.org/api/composition-api-helpers#useid
<script setup>
import { useId } from 'vue'
const id = useId()
</script>
<template>
<form>
<label :for="id">Name:</label>
<input :id="id" type="text" />
</form>
</template>