Skip to main content
Vuetify0 Logo
Theme
Mode
Palettes
Accessibility
Vuetify One
Sign in to Vuetify One

Access premium tools across the Vuetify ecosystem — Bin, Play, Studio, and more.

Not a subscriber? See what's included

createRegistry

Foundation for ordered, keyed collections. Items are registered with IDs and indexes, and can be looked up by ID, index, or value.

Edit
Report a Bug
Issues
Source
Markdown

StableAdvancedNov 3, 2026

Usage

The createRegistry composable provides a powerful interface for managing collections of items in a registration-based system. It allows you to register, unregister, and look up items efficiently, while maintaining an index for quick access.

Pass both generics: the input shape you hand to register() first, the resolved ticket you read back second. With only the input type, ticket.value widens to string | undefined; passing the output type alone is reserved for wrappers that fix their own ticket shape, such as createForm and createQueue.

ts
import { createRegistry } from '@vuetify/v0'
import type { RegistryTicket, RegistryTicketInput } from '@vuetify/v0'

interface ItemInput extends RegistryTicketInput<string> {
  label: string
}

type Item = RegistryTicket<string> & ItemInput

const registry = createRegistry<ItemInput, Item>()

// Register individual items
const a = registry.register({ value: 'alpha', label: 'Alpha' })
const b = registry.register({ value: 'beta', label: 'Beta' })
const c = registry.register({ value: 'gamma', label: 'Gamma' })

console.log(registry.size) // 3
console.log(a.index)       // 0

// Look up by id
const found = registry.get(b.id)
console.log(found?.label)  // 'Beta'

// Patch a field without replacing the ticket
registry.upsert(b.id, { label: 'Beta (updated)' })

// Move to a new position
registry.move(a.id, 2)
console.log(a.index)       // 2

// Remove one
registry.unregister(c.id)
console.log(registry.size) // 2

// Bulk load
registry.onboard([
  { id: 'x', value: 'x', label: 'X' },
  { id: 'y', value: 'y', label: 'Y' },
])

// Bulk remove
registry.offboard(['x', 'y'])

Context / DI

Use createRegistryContext to share a registry across a component tree. Pass a fresh createRegistry() to the provider so each app instance owns its registry, created with the same options: what you pass to createRegistryContext only configures the module-scope default that a bare provideItems() would provide.

ts
import { createRegistry, createRegistryContext } from '@vuetify/v0'

export const [useItems, provideItems, items] =
  createRegistryContext({ namespace: 'my:items', events: true })

// In the root component — one registry per app instance, with the same options
provideItems(createRegistry({ events: true }))

// In child components
const registry = useItems()
registry.register({ id: 'item-1', value: 'First' })

Architecture

createRegistry is the foundation for specialized registration systems:

Registry Hierarchy

Use controls to zoom and pan. Click outside or press Escape to close.

Registry Hierarchy

Each branch extends the base ticket pattern with domain-specific capabilities. See individual composable docs for their extension hierarchies.

Reactivity

createRegistry uses minimal reactivity by default for performance. Collection methods are not reactive unless you opt in.

MethodNotes
register(ticket)Append a ticket to the registry; a supplied index is ignored — use move() to position
unregister(id)Remove a ticket by ID
upsert(id, partial)Register or update a ticket
move(id, index)Move a ticket to a new index position; reindexes only the affected [from..to] span
reorder(ids)Reorder the registry to match a canonical permutation in one O(n) pass
onboard(tickets)Batch-register an array of tickets
offboard(ids)Batch-unregister an array of IDs
batch(fn)Run multiple mutations with events and the reactive notification deferred to the end
get(id)Retrieve a ticket by ID
has(id)Check whether a ticket ID is registered
browse(value)Reverse-lookup — find ticket ID(s) by value
lookup(index)Find ticket ID by zero-based index
seek(direction, from?, predicate?)Find 'first' or 'last' ticket, optionally starting from an index and/or filtered by predicate
keys()All registered IDs as a readonly array
values()All registered tickets as a readonly array
entries()All [id, ticket] pairs as a readonly array
clear()Remove all tickets
dispose()Remove all tickets and clear event listeners
Tip

Need reactive collections? Pass { reactive: true } to make keys(), values(), entries(), size, and per-ticket field reads reactive in templates and computeds. Upserts on existing tickets propagate through the shallowReactive wrapping. For event-driven snapshots — or when you want deep: true tracking or need reactivity without wrapping the tickets themselves — use useProxyRegistry with { events: true }.

Examples

Task Manager

This example demonstrates the full createRegistry lifecycle paired with createContext so registry mutations stay encapsulated in the provider and the consumer only sees a reactive useProxyRegistry view plus clean, typed methods.

Event Flow

Use controls to zoom and pan. Click outside or press Escape to close.

Event Flow

File breakdown:

FileRole
context.tsDefines TaskTicketInput (extending RegistryTicketInput) and TaskContext, then creates the [useTaskRegistry, provideTaskRegistry] tuple
TaskProvider.vueCreates the registry with events: true, wraps it in useProxyRegistry, wires lifecycle listeners, seeds initial data via onboard, and exposes the proxy and mutation methods through context
TaskConsumer.vueCalls useTaskRegistry() to read proxy.values and the mutation methods; owns local UI state (filter, new-task input) and derives filteredTasks and stats as computed
task-manager.vueEntry point—composes TaskProvider around TaskConsumer

Key patterns:

  • onboard — bulk-loads the initial task list in a single batch

  • registry.register() — adds a ticket with custom fields (value, priority, done)

  • registry.upsert() — patches a single field without touching the rest of the ticket

  • registry.offboard() — batch-removes all completed tasks in one call

  • registry.on('register:ticket') / on('unregister:ticket') — reacts to lifecycle events for the audit log

  • useProxyRegistry(registry) — the registry is events: true, so iterate through the proxy’s reactive values and size (or opt into reactive: true) rather than a hand-rolled version counter

Add tasks, toggle completion, and filter by priority. Watch the event log at the bottom track every registration change in real time.

5 tasks1 done2 high priority registry.size = 5
Set up CI pipelinehigh#0
Write unit testsmedium#1
Update READMElow#2
Review PR #42high#3
Refactor auth modulemedium#4

Event log

+ Registered "Set up CI pipeline"

+ Registered "Write unit tests"

+ Registered "Update README"

+ Registered "Review PR #42"

+ Registered "Refactor auth module"

Theme
Mode
Palettes
Accessibility

FAQ

Discord
Need help? Join our community for support and discussions ↗

API Reference

The following API details are for the createRegistry composable.
Was this page helpful?

© 2016-1970 Vuetify, LLC
Services
Ctrl+/