# prefer-use-template-ref

Rule `vue/prefer-use-template-ref`. Require using `useTemplateRef` instead of `ref`/`shallowRef` for template refs

- Source: vue
- Technologies: Vue
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 0 weekly downloads of presets that enable it
- Trend: 0% last quarter
- Rank: #1847 by reach

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| ESLint | `vue/prefer-use-template-ref` | no | no | package `eslint-plugin-vue` | [docs](https://eslint.vuejs.org/rules/prefer-use-template-ref.html) |
| Biome | `nursery/useVueTemplateRef` | no | no | group nursery, since 2.6.4 | [docs](https://biomejs.dev/linter/rules/use-vue-template-ref/) |

## Code examples

### Incorrect: the rule reports this

```vue
<template>
  <input ref="input" />
</template>

<script setup>
import { ref } from "vue";

const input = ref();
</script>
```

```vue
<template>
  <div ref="root" />
</template>

<script setup>
import { shallowRef } from "vue";

const root = shallowRef(null);
</script>
```

### Correct: the rule accepts this

```vue
<template>
  <input ref="input" />
  <button :ref="(el) => (button = el)">Send</button>
</template>

<script setup>
import { ref, useTemplateRef } from "vue";

const inputElement = useTemplateRef("input");
const button = ref();
</script>
```

Examples from the Biome documentation.

## Enable it

### ESLint: `eslint.config.js`

```js
import vue from "eslint-plugin-vue";

export default [
  {
    plugins: { vue },
    rules: {
      "vue/prefer-use-template-ref": "error",
    },
  },
];
```

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "nursery": {
        "useVueTemplateRef": "error"
      }
    }
  }
}
```

## Related rules

- [vue/prefer-true-attribute-shorthand](https://lintradar.dev/rules/vue/prefer-true-attribute-shorthand.md): Require shorthand form attribute when `v-bind` value is `true`
- [vue/require-emit-validator](https://lintradar.dev/rules/vue/require-emit-validator.md): Require type definitions in emits
- [vue/prefer-single-event-payload](https://lintradar.dev/rules/vue/prefer-single-event-payload.md): Enforce passing a single argument to custom event emissions
- [vue/require-explicit-slots](https://lintradar.dev/rules/vue/require-explicit-slots.md): Require slots to be explicitly defined
- [vue/prefer-prop-type-boolean-first](https://lintradar.dev/rules/vue/prefer-prop-type-boolean-first.md): Enforce `Boolean` comes first in component prop types
- [vue/require-macro-variable-name](https://lintradar.dev/rules/vue/require-macro-variable-name.md): Require a certain macro variable name

---

Web page: https://lintradar.dev/rules/vue/prefer-use-template-ref. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
