Plugins are the entry point for extending the Nuxe runtime. Every file insideDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/dvlkit/nuxe/llms.txt
Use this file to discover all available pages before exploring further.
app/plugins/ is executed once before the root Vue component mounts, giving you access to the Vue app instance, the router, runtime config, and a lifecycle hook system. Common use cases include registering global Vue components, installing third-party libraries, and attaching route-level analytics.
File naming conventions
Nuxe scansapp/plugins/ and registers each file automatically. The suffix in the file name controls the execution environment:
| File name | Runs on |
|---|---|
hello.ts | Server and client |
client-only.client.ts | Client only |
server-only.server.ts | Server only |
_ are ignored by the scanner — use this for private helpers shared between plugins.
defineNuxePlugin
Wrap every plugin export in defineNuxePlugin. It accepts either a plain setup function or an object with a setup function and optional configuration flags.
Plugins marked
parallel: true are started concurrently alongside other parallel plugins instead of being awaited in sequence. Use this for setup tasks that are fully independent — for example, pre-fetching config from two different endpoints at the same time.The NuxeApp object
The single argument passed to your plugin’s setup function is a NuxeApp instance with the following properties:
The underlying Vue 3 application instance. Use this to call
vueApp.component(), vueApp.directive(), or vueApp.use() to register Vue-level extensions.The Vue Router instance. Useful for registering global navigation guards or accessing the current route outside of a component.
The server-side rendering context object. Only present during SSR;
undefined on the client. Use it to access request-scoped data passed from the server entry.The runtime configuration object.
config.public contains values accessible on both the server and the client; private keys are server-only.Shared reactive state passed from SSR to the client hydration payload. Use
useState to read and write individual keys.The full SSR payload object that is serialised into the initial HTML and rehydrated on the client.
payload.state is a reference to the same object as state.Register a listener for a lifecycle hook. The listener is called every time the named event fires.
Programmatically fire a lifecycle hook. Returns a
Promise that resolves after all registered listeners complete.Available lifecycle hooks
| Hook name | When it fires |
|---|---|
app:created | Immediately after the Nuxe app object is constructed, before any plugins run |
app:mounted | After the Vue app has mounted in the browser |
page:start | Before a page navigation begins |
page:finish | After a page navigation completes |
Real-world plugin examples
useNuxeApp()
Inside a Vue component’s setup function or inside another plugin, call useNuxeApp() to access the NuxeApp instance without it being passed as an argument: