---
source: https://iinventedlight.com/library/notes/vue-custom-directives.md
title: "Register a Vue custom directive for low-level DOM access"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "CC-BY-4.0 (Vue docs); CC-BY-4.0 (Vue docs); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "Summary by iinventedlight (AI-assisted). Sources: Vue docs, Custom Directives; Vue docs, Application API. CC-BY-4.0; CC-BY-4.0."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-19
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-19
as_of: 2026-11-19
confidence: medium
untested: "Not reproduced (2026-11-19). Official docs and source files were read; no test suite, server, or API call was run for this note."
category: coding-references
topic_area: "code-web: Vue custom directives"
tags: [vue, directives, dom, app.directive]
client: Librarian
sources:
  - id: S1
    title: "Custom Directives"
    publisher: Vue docs
    url: https://vuejs.org/guide/reusability/custom-directives.html
    accessed: 2026-11-19
    license: "CC-BY-4.0"
  - id: S2
    title: "Application API"
    publisher: Vue docs
    url: https://vuejs.org/api/application.html
    accessed: 2026-11-19
    license: "CC-BY-4.0"
---
# Register a Vue custom directive for low-level DOM access
**Answer:** Vue ships core directives such as `v-model` and `v-show`, and you can register your own custom directives. They are aimed at reusing logic that needs low-level DOM access on plain elements, not at replacing components or composables.

## Hooks on the element

A custom directive is an object of lifecycle hooks, similar to a component. Those hooks receive the element the directive is bound to. Components remain the main building blocks, and composables reuse stateful logic. One example directive adds a class to an element.

## Global registration

`app.directive` on the application instance registers a global custom directive when you pass a name string and a directive definition. If you pass only the name, it retrieves an already registered directive. `app.directive` registers the directive on the application instance.

| custom directives | app.directive |
|---|---|
| v-model and v-show | Default directives shipped in core |
| custom directive | Object of lifecycle hooks bound to an element |
| components and composables | Main reuse tools beside directives |
| app.directive | Registers or retrieves a global directive |

## See also

- [vue-composables](https://iinventedlight.com/library/notes/vue-composables/)
- [vue-lifecycle-hooks](https://iinventedlight.com/library/notes/vue-lifecycle-hooks/)
- [vue-template-syntax](https://iinventedlight.com/library/notes/vue-template-syntax/)

## Claims

- id: C1
  claim: Besides core directives such as v-model and v-show, Vue lets you register custom directives.
  source: S1
  evidence: "register your own custom directives"

- id: C2
  claim: Custom directives are meant for reuse of low-level DOM access on plain elements.
  source: S1
  evidence: "low-level DOM access on plain elements"

- id: C3
  claim: app.directive registers a global custom directive, or retrieves one by name.
  source: S2
  evidence: "Registers a global custom directive"

## Sources

- [S1] Custom Directives. Vue docs. https://vuejs.org/guide/reusability/custom-directives.html . License: CC-BY-4.0. Accessed 2026-11-19.

- [S2] Application API. Vue docs. https://vuejs.org/api/application.html . License: CC-BY-4.0. Accessed 2026-11-19.

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: Vue docs, Custom Directives; Vue docs, Application API. CC-BY-4.0; CC-BY-4.0. Text was condensed and changed from the originals.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
