Discover how tiny, fast components can make your Vue app feel lightning quick!
Why Functional components in Vue? - Purpose & Use Cases
Imagine building a Vue app where every small UI part needs its own component, but you write full component code with data, methods, and lifecycle hooks even for simple display parts.
This approach makes your code bulky and slow because Vue has to manage extra overhead like reactivity and lifecycle for components that just show static content or simple props.
Functional components let you write lightweight, stateless components that only render UI based on props, making your app faster and your code cleaner.
<template><div>{{ message }}</div></template>
<script>export default { props: ['message'], data() { return {}; }, methods: {}, mounted() {} }</script>export default {
functional: true,
props: ['message'],
render(h, { props }) {
return h('div', props.message)
}
}It enables building fast, simple UI pieces without unnecessary overhead, improving app performance and developer productivity.
Think of a button component that only shows a label and triggers a click. Using a functional component makes it super light and quick to render everywhere.
Functional components are simple, stateless, and faster.
They reduce code size by skipping lifecycle and reactivity.
Perfect for small UI parts that just display props.