Core Composables

API reference for configuration, UI state, clipboard, analytics, and routing composables provided by @nuxtify/core.

Overview

  • Provided by: @nuxtify/core (re-typed by @nuxtify/pages and @nuxtify/cms where extended)
  • Source directory: src/runtime/composables/

All composables below are auto-imported across your Nuxt app with lower import priority (-30), so creating a composable with the same name in app/composables/ cleanly overrides the built-in implementation.

Configuration & Head

useNuxtifyConfig()

Returns the resolved useAppConfig().nuxtify configuration object with full TypeScript types matching the highest Nuxtify module installed in your project.

const nuxtifyConfig = useNuxtifyConfig()
console.log(nuxtifyConfig.brand?.name)

useNuxtifySiteTitle(options?)

Configures Unhead's titleTemplate as %s <separator> <siteName>, defaulting to brand.name from useNuxtifyConfig().

useNuxtifySiteTitle({
  separator: '|', // default: '|'
  siteName: '', // default: nuxtifyConfig.brand?.name
})

Global UI State

useDialog()

Returns a Nuxt useState<Dialog>('dialog') ref bound to AppDialog.

export interface Dialog {
  show: boolean
  title: string
  message: string
  action: {
    button: {
      color?: string
      text: string
      prependIcon?: string
      appendIcon?: string
    }
    function: (() => Promise<void>) | (() => void) | null
    loading?: boolean
  }
  closeButtonText: string
}
const dialog = useDialog()

function confirmDelete() {
  dialog.value = {
    ...dialogInitialState,
    show: true,
    title: 'Delete item?',
    message: 'This action cannot be undone.',
    action: {
      button: { text: 'Delete', color: 'error' },
      function: async () => {
        dialog.value.action.loading = true
        await deleteItem()
        dialog.value.show = false
      },
      loading: false,
    },
  }
}

dialogInitialState is also exported from dialog.ts so you can reset all dialog fields cleanly.

useToast()

Returns a Nuxt useState ref ({ show: boolean, message: string }) bound to AppToast.

const toast = useToast()
toast.value.message = 'Settings saved!'
toast.value.show = true

useDrawer()

Returns useState<boolean | null>('drawer', () => null) controlling the mobile AppNavigationDrawer toggled from AppHeader.

useErrorMessage()

Returns useState<string>('errorMessage', () => '') bound to AppError.

Routing, Clipboard & Analytics

useRouteParam(param)

Wraps useRoute() and returns route.params[param] normalized to a string (taking the first element if it is an array, or '' if missing).

const slug = useRouteParam('slug') // string

useCopyText

useCopyText(text, label?) copies text to the user's clipboard using navigator.clipboard.writeText and displays a confirmation (or unavailability error) through useToast().

ParameterTypeDefaultDescription
textstringRequiredText to write to the clipboard.
labelstring'Text'Prefix shown in the toast message ("${label} copied!").

useAnalytics()

Lightweight analytics hook interface called by Nuxtify components (for example, EmailSubscribeForm calls userSignUp() after a successful form submission). By default, each method logs to the console only when verboseLogs: true. Override app/composables/useAnalytics.ts to forward events to your analytics provider (PostHog, Plausible, GA4, etc.).

Returned Methods

MethodSignatureDescription
userSignUp() => voidFires when a user signs up or subscribes.
userSignIn() => voidFires when a user signs in.
userSignOut() => voidFires when a user signs out.
userUpgrade(planId: string) => voidFires when a user upgrades to a paid plan.