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

Plugins

Vuetify0 plugins are Vue plugins built with createPlugin. They provide app-wide singletons for features like theming, locale, and logging. For understanding the underlying architecture, see Core.

Edit
Report a Bug
Markdown

AdvancedOct 28, 2026

Using Built-in Plugins

Basic Installation

Vue installs plugins from main.ts. Nuxt installs them from plugins/v0.ts.

main.ts
import { createApp } from 'vue'
import { createThemePlugin, createLocalePlugin } from '@vuetify/v0'

const app = createApp(App)

// Install plugins
app.use(createThemePlugin())
app.use(createLocalePlugin())

app.mount('#app')

With Options

ts
app.use(
  createThemePlugin({
    default: 'dark',
    themes: {
      light: { dark: false, colors: { primary: '#1976D2' } },
      dark: { dark: true, colors: { primary: '#2196F3' } },
    },
  }),
)

app.use(
  createLocalePlugin({
    default: 'en',
    messages: { en: { hello: 'Hello' } },
  }),
)

Available Plugins

PluginPurposeComposable
createThemePluginCSS variable theming, dark modeuseTheme
createLocalePlugini18n translationsuseLocale
createRtlPluginRTL direction supportuseRtl
createLoggerPluginStructured logginguseLogger
createStoragePluginReactive localStorage/sessionStorageuseStorage
createPermissionsPluginRole-based access controlusePermissions
createBreakpointsPluginResponsive breakpoint detectionuseBreakpoints
createHydrationPluginSSR hydration managementuseHydration
createFeaturesPluginFeature flags with adapter supportuseFeatures
createRulesPluginValidation rule aliases and Standard SchemauseRules
createDatePluginDate utilities with adapter patternuseDate
createNotificationsPluginNotification lifecycle and toast queueuseNotifications
createStackPluginOverlay z-index stackinguseStack
createReducedMotionPluginRespect or override prefers-reduced-motionuseReducedMotion
createTooltipPluginRegion-scoped tooltip delay coordinationuseTooltip
createPopoverPluginApp-wide popover positioning adapterusePopover
Tip

All plugins are optional. Only install what you need—Vuetify0 works without any plugins installed.

Ask AI
Which built-in plugins do I actually need? Can I use Vuetify0 without them?

Nuxt

Nuxt registers every file in plugins/ for you. Put the Vuetify0 plugins in plugins/v0.ts and install them on nuxtApp.vueApp. There is no Vuetify0 Nuxt module.

Add @vuetify/v0 to build.transpile. A second createThemePlugin() is skipped, so delete Getting Started’s plugins/vuetify0.ts if you copied it. That file uses the default theme adapter, which writes no CSS during SSR. Use createThemePlugin with V0UnheadThemeAdapter instead. The following is an example of how you could set up plugins/v0.ts.

plugins/v0.ts
import { createBreakpointsPlugin, createHydrationPlugin, createThemePlugin } from '@vuetify/v0'
import { V0UnheadThemeAdapter } from '@vuetify/v0/theme/adapters/unhead'

export default defineNuxtPlugin((nuxtApp) => {
  const themeCookie = useCookie<'light' | 'dark'>('theme')
  const widthCookie = useCookie<number>('viewport-width', {
    default: () => 1280,
  })

  nuxtApp.vueApp.use(createHydrationPlugin())
  nuxtApp.vueApp.use(
    createBreakpointsPlugin({
      ssr: {
        clientWidth: widthCookie.value || 1280,
      },
    }),
  )
  nuxtApp.vueApp.use(
    createThemePlugin({
      adapter: new V0UnheadThemeAdapter(),
      default: themeCookie.value === 'dark' ? 'dark' : 'light',
      themes: {
        light: {
          dark: false,
          colors: {
            primary: '#3b82f6',
            surface: '#ffffff',
            'on-primary': '#ffffff',
            'on-surface': '#212121',
          },
        },
        dark: {
          dark: true,
          colors: {
            primary: '#60a5fa',
            surface: '#1e1e1e',
            'on-primary': '#1a1a1a',
            'on-surface': '#e0e0e0',
          },
        },
      },
    }),
  )
})
nuxt.config.ts
export default defineNuxtConfig({
  build: {
    transpile: ['@vuetify/v0'],
  },
})

V0UnheadThemeAdapter writes the theme <style> tag through Unhead, which Nuxt already runs. ssr.clientWidth is the width both the server render and the hydration render share. createHydrationPlugin() keeps isHydrated false until the root has mounted.

Leave persist and system off on createThemePlugin. The server cannot read localStorage or the operating system’s color scheme. The theme cookie is the value both renders share.

Install any other plugin in this same callback, with another nuxtApp.vueApp.use(...).

app.vue stores theme and viewport-width after the client mounts. The Nuxt guide has those watches, plus auto-imports and hydration mismatches.

Ask AI
How do I install Vuetify0 plugins in a Nuxt app?

Creating Custom Plugins

Using createPluginContext

createPluginContext is the recommended factory for new plugins. It generates the full [createXContext, createXPlugin, useX] tuple in a single call, eliminating the boilerplate of wiring together createContext and createPlugin manually.

Log through useLogger. The factory runs while the plugin installs, so register the logger plugin first and this one picks it up. Debug lines show when the logger level is debug or lower.

src/plugins/analytics.ts
import { createPluginContext, useLogger } from '@vuetify/v0'

interface AnalyticsContext {
  track: (event: string, data?: Record<string, unknown>) => void
  identify: (userId: string) => void
}

interface AnalyticsOptions {
  apiKey: string
  debug?: boolean
}

export const [createAnalyticsContext, createAnalyticsPlugin, useAnalytics] =
  createPluginContext<AnalyticsOptions, AnalyticsContext>(
    'my:analytics',
    ({ apiKey, debug = false }) => {
      const logger = useLogger('analytics')

      return {
        track: (event, data) => {
          if (debug) logger.debug('Track', { event, data })
          // send to analytics service using apiKey
        },
        identify: (userId) => {
          // identify user
        },
      }
    },
  )
main.ts
import { createLoggerPlugin } from '@vuetify/v0'
import { createAnalyticsPlugin } from './plugins/analytics'

app.use(createLoggerPlugin({ level: 'debug' }))
app.use(createAnalyticsPlugin({ apiKey: 'xxx', debug: true }))
MyComponent.vue
<script setup>
  import { useAnalytics } from './plugins/analytics'
  const analytics = useAnalytics()
  analytics.track('page_view')
</script>
Tip

createPluginContext also supports persist/restore lifecycle hooks for automatically saving and rehydrating plugin state across page loads. See createPlugin for details.

Manual Approach

For fine-grained control over the plugin lifecycle, use createContext and createPlugin directly. Call useLogger() inside provide. That hook runs during app.use(), after plugins you installed earlier.

src/plugins/analytics.ts
import { createContext, createPlugin, useLogger } from '@vuetify/v0'

interface AnalyticsContext {
  track: (event: string, data?: Record<string, unknown>) => void
  identify: (userId: string) => void
}

// 1. Create the context for DI
const [useAnalytics, provideAnalytics] = createContext<AnalyticsContext>('my:analytics')

// 2. Create the plugin factory
export function createAnalyticsPlugin() {
  return createPlugin({
    namespace: 'my:analytics',
    provide: (app) => {
      const logger = useLogger('analytics')

      provideAnalytics({
        track: (event, data) => {
          logger.info('Track', { event, data })
        },
        identify: (userId) => {
          logger.info('Identify', { userId })
        },
      }, app)
    },
  })
}

export { useAnalytics }

Plugin with Options

src/plugins/analytics.ts
interface AnalyticsOptions {
  apiKey: string
  debug?: boolean
}

export function createAnalyticsPlugin(options: AnalyticsOptions) {
  const { apiKey, debug = false } = options

  return createPlugin({
    namespace: 'my:analytics',
    provide: (app) => {
      const logger = useLogger('analytics')

      provideAnalytics({
        track: (event, data) => {
          if (debug) logger.debug('Track', { event, data })
          // Send to analytics service using apiKey
        },
        identify: (userId) => {
          // Identify user
        },
      }, app)
    },
  })
}

// Usage
app.use(createAnalyticsPlugin({ apiKey: 'xxx', debug: true }))

Plugin with Adapter Pattern

For a plugin that can talk to more than one backend, pass an adapter. Log with useLogger from @vuetify/v0.

src/plugins/analytics.ts
import { createContext, createLoggerPlugin, createPlugin, useLogger } from '@vuetify/v0'

interface AnalyticsAdapter {
  track: (event: string, data?: Record<string, unknown>) => void
  identify: (userId: string) => void
}

interface AnalyticsContext {
  track: (event: string, data?: Record<string, unknown>) => void
  identify: (userId: string) => void
}

interface AnalyticsOptions {
  adapter?: AnalyticsAdapter
}

const defaultAdapter: AnalyticsAdapter = {
  track: () => {},
  identify: () => {},
}

const [useAnalytics, provideAnalytics] = createContext<AnalyticsContext>('my:analytics')

export function createAnalyticsPlugin(options: AnalyticsOptions = {}) {
  const adapter = options.adapter ?? defaultAdapter

  return createPlugin({
    namespace: 'my:analytics',
    provide: (app) => {
      const logger = useLogger('analytics')

      provideAnalytics({
        track: (event, data) => {
          logger.debug('Track', { event, data })
          adapter.track(event, data)
        },
        identify: (userId) => {
          logger.info('Identify', { userId })
          adapter.identify(userId)
        },
      }, app)
    },
  })
}

export { useAnalytics }

const httpAdapter: AnalyticsAdapter = {
  track: (event, data) => {
    void fetch('/analytics', {
      method: 'POST',
      body: JSON.stringify({ event, data }),
    })
  },
  identify: (userId) => {
    void fetch('/analytics/identify', {
      method: 'POST',
      body: JSON.stringify({ userId }),
    })
  },
}

app.use(createLoggerPlugin({ level: 'debug' }))
app.use(createAnalyticsPlugin({ adapter: httpAdapter }))

Consuming Plugins

vue
<script setup>
  import { useTheme, useLocale } from '@vuetify/v0'

  const theme = useTheme()
  const locale = useLocale()

  // Theme API
  theme.cycle()              // Cycle through themes
  theme.select('dark')       // Select specific theme
  theme.selectedItem.value   // Current theme ticket
  theme.selectedId.value     // 'light' | 'dark'
  theme.isDark.value         // boolean

  // Locale API
  locale.t('hello')
  locale.selectedItem.value  // Current locale ticket
  locale.selectedId.value    // 'en'
</script>

Plugin vs Context

NeedUse
App-wide singleton (one instance)Plugin with app.use()
Multiple instances per subtreeContext with provideContext
Configurable at install timePlugin
Configurable per component treeContext

Best Practices

1. Provide Default Adapters

ts
// Always provide a sensible default
const defaultAdapter = { /* ... */ }
const adapter = options.adapter ?? defaultAdapter

2. Type the Context Interface

ts
// Define what consumers get
interface ThemeContext {
  selectedId: ComputedRef<string>
  select: (id: string) => void
  cycle: () => void
}

3. Handle Missing Installation

ts
const theme = useTheme()
// useTheme throws if createThemePlugin isn't installed
// This is intentional - fail fast
Was this page helpful?

© 2016-1970 Vuetify, LLC
Services
Ctrl+/