.vue component is the primary way to render Vue components within Phoenix LiveView templates.
Basic syntax
Required attributes
Name of the Vue component to render (e.g., “Counter”, “admin/Dashboard”).The value is directly passed to the
resolve function of the createLiveVue instance. It should return a Vue component or a promise that resolves to a Vue component. In a standard setup, you can find this in assets/vue/index.js.LiveView socket. Must be provided when rendering inside a LiveView.
Optional attributes
Explicit ID for the wrapper component. If not provided, a random one will be generated.Useful to keep ID consistent in development.
CSS class(es) to apply to the Vue component wrapper.
Whether to render the component on the server. Defaults to the value set in config.
Whether to enable props diffing for this component. When enabled, only changed props are sent over the WebSocket.
Event handlers
Vue event handlers can be attached using the When using
v-on: prefix followed by the event name.JS.push() without a value, the emit payload is automatically used:Props and slots
All other attributes not listed above are passed as props to the Vue component.Props
Props are JSON-encoded and sent to the Vue component. You need to provide serializable types or implement theJason.Encoder protocol for custom types.
Slots
Slots can be passed as regular Phoenix slots.Examples
Basic component
Component with events
Component with complex props
Component with slots
Nested component path
Component with custom styling
Component with SSR disabled
Source
Seelib/live_vue.ex:82 for the complete implementation.