Skip to content

Latest commit

History

History
44 lines (31 loc) 路 1.18 KB

+Page.mdx

File metadata and controls

44 lines (31 loc) 路 1.18 KB

import { Link } from '@brillout/docpress' import { ImplementedBy } from '../../components'

Environment: server, client. <ImplementedBy by={vike-vue} noCustomGuide={true}>onCreateApp() hook

The onCreateApp() hook is called right after the Vue app is created, giving you the opportunity to extend it, typically for registering a Vue plugin.

// /pages/+onCreateApp.js
// Environment: server, client

export { onCreateApp }

import SomeVuePlugin from 'some-vue-plugin'

const onCreateApp = (pageContext) => {
  const { app } = pageContext
  app.use(SomeVuePlugin)
}

Examples

See vike-vue > /examples/with-vue-plugin

TypeScript

// /pages/+onCreateApp.ts
// Environment: server, client

export { onCreateApp }

import type { OnCreateAppSync } from 'vike-vue'
import SomeVuePlugin from 'some-vue-plugin'

const onCreateApp: OnCreateAppSync = (pageContext): ReturnType<OnCreateAppSync> => {
  const { app } = pageContext
  app.use(SomeVuePlugin)
}