Reference

Magic variables

There are 40 of them, available in any expression without declaring anything. They exist because window, document and V itself are not allowed inside expressions: this is how an expression reaches the DOM and the services.

<div v-data="{}">
  <button @click="$toast.success('Saved!')">Notify</button>
  <button @click="$clipboard.copy('PROMO10')">Copy the coupon</button>
  <button @click="$refs.search.focus()">Focus</button>
  <input v-ref="search" placeholder="I am the one getting the focus">
  <p>Screen width: { $screen.width }px · Online: { $network.online }</p>
</div>

Context

MagicWhat it is
$elThe element that created the scope
$refsElements marked with v-ref, merging the ancestor scopes
$dataData of the current scope
$rootData of the root scope
$parentData of the parent scope
$selfInstance of the nearest component, or the scope data

State and services

MagicWhat it is
$storeEvery global store
$httpHTTP client
$toastNotifications
$modal, $dialog, $alert, $confirm, $promptDialogs
$storage, $session, $cookie, $cache, $urlStorage
$clipboardCopying to and reading from the clipboard
$themeLight and dark theme
$soundSound effects
$formState of the nearest form
$historyUndo and redo controller, when there is a v-history above
Not every read is reactive

$store, $theme, $screen, $network, $route and $form read reactive state, and the screen follows along. $storage, $session, $cookie, $cache and $url read at the moment the expression runs: keep the result in a scope variable when the screen has to react to it.

Environment

MagicWhat it is
$screenWidth, height and breakpoints, reactive
$networkState of the connection, reactive
$deviceTouch, size, motion and theme

Flow

MagicWhat it is
$nextTickWaits for the DOM to catch up
$watch(expression, cb)Watches an expression
$dispatch(name, detail?)Fires a CustomEvent that travels up the tree
$log(...)Writes to the console with a [Voodoo] prefix

In the full build only

MagicWhat it is
$routeThe current route
$routerNavigation control
$tTranslates
$localeThe active language
$i18nThe languages module
$n, $c, $d, $rtNumber, currency, date and relative time

Local ones

These exist only inside certain expressions:

VariableWhere
$eventEvent handlers
$detailEvent handlers, carrying the detail of the CustomEvent
$value, $oldv-watch combined with v-model
$data, $responsev-on-success and v-on-error on forms

Writing your own

V.magic('$user', () => loggedUser);
V.magic('$format', () => (value) => V.formatCurrency(value));
V.magic('$height', (scope) => scope.el.offsetHeight);

The getter receives the active scope, so a magic can depend on where it was used. The dollar sign is added for you when you leave it out, and magics are read-only, except for the ones that expose a set method of their own. V.magics is the Map holding every registered one. The custom directives and plugins page has the full example.