---
category: Component
---
::: info
This function will be removed in future version.
Vue 3.5 introduced the `useTemplateRef` API which can effectively replace the functionality of `templateRef`, therefore we recommend using the native approach.
:::
# templateRef
Shorthand for binding ref to template element.
## Usage
```vue
```
### With JSX/TSX
```tsx
import { templateRef } from '@vueuse/core'
export default {
setup() {
const target = templateRef('target', null)
// use string ref
return () =>
},
}
```
### `
```
## Type Declarations
```ts
/**
* @deprecated Use Vue's built-in `useTemplateRef` instead.
*
* Shorthand for binding ref to template element.
*
* @see https://vueuse.org/templateRef
* @param key
* @param initialValue
*
* @__NO_SIDE_EFFECTS__
*/
export declare function templateRef<
T extends HTMLElement | SVGElement | Component | null,
Keys extends string = string,
>(key: Keys, initialValue?: T | null): Readonly[>
```
]