Vue · Template

VUE0035Key stateful v-for items by a stable id

Reports v-for keys bound to the iteration index when the keyed element holds state: a component whose source keeps local state, an element with v-model, a native form control, or a child of <TransitionGroup>.

Why it happens

Vue reuses DOM nodes and component instances by key. With an index key, inserting, removing or reordering items keeps each instance at its position, so component state, input values and transitions attach to a different item.

Fix

Key each item by a stable, unique field of the item itself, such as its id.

Example

Key a component list by item id

Before

<script setup lang="ts">
import TodoRow from "./TodoRow.vue"; // keeps a draft in ref()
</script>
<template>
  <TodoRow v-for="(todo, index) in todos" :key="index" :todo="todo" />
</template>

After

<script setup lang="ts">
import TodoRow from "./TodoRow.vue"; // keeps a draft in ref()
</script>
<template>
  <TodoRow v-for="todo in todos" :key="todo.id" :todo="todo" />
</template>

Verify the fix

Run only this rule after editing so the report stays focused on the diagnostic you are closing:

pnpm vite-doctor . --framework vue --rules vue/template/no-index-key-on-stateful-list
Copyright © 2026