# ref Register a reference to an element or a component. ## Usage ```html
``` ## Details The `ref` attribute allows you to register a direct reference to a specific DOM element or child component instance. The reference will be accessible under the `$refs` object of the current scope. Refs are populated after the component is mounted. They are not reactive, so you should not use them in templates for data binding. ## Refs Are Always Elements `$refs` entries are DOM elements, never scope objects — Lune has no component instances to hand back. A `ref` on an element that also carries `lu-scope` is registered in both that element's own `$refs` and its parent's, so an outer scope can reach the element: ```html
{{ count }}
``` To call into a child's logic, share state instead of reaching for the element — put the value or method on a parent scope, or on a [store](/advanced/state-management) both scopes read. ## Dynamic Names The `ref` value is an expression, so a name can be computed. When it changes, the old key is removed from `$refs` and the new one registered; when the element is unmounted, its key is removed. ```html
```