Vue · VUE0035

Key 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>.
VUE0035vite-doctor/vuetemplatewarnNo fix

Run this rule

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

Why it matters

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.

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>
Copyright © 2026