About
Projects
BlogWhere I write, think and learn.GallerySometimes I also take photos.WrappedA recap of what's been on rotation lately.
Blog
Gallery
Wrapped
© 2026 /Gilang Fatahilah

← Notebook · Entry No.03 · December 7, 2025 · 5 min read

Avoiding Props Drilling in Vue.js: 4 Effective Solutions You Need to Know

Props drilling often becomes an issue as Vue 3 applications grow larger. This article discusses 4 effective solutions to avoid props drilling with real-world examples using the Composition API.

filed under Vue, Javascript, Front-end

Avoiding Props Drilling in Vue.js: 4 Effective Solutions You Need to Know
Pass this page on

Introduction

When building applications using Vue 3, we often start with a simple component structure. However, as features are added, the component structure also becomes more complex. This is where a problem called props drilling often arises. Props drilling occurs when data must be sent from the top component to the deepest child component, passing through many layers of intermediate components that do not actually need the data. This problem may seem trivial at first, but it can become a nightmare in terms of:
  • Maintenance
  • Scalability
  • Debugging
  • Component reusability
In this article, we will discuss what props drilling is and 4 effective solutions to avoid it in Vue 3.

What is Props Drilling?

Props drilling is a condition where data must be continuously sent from parent to child, then to the next child, even though the intermediate components do not need it. Common structures that often occur: code example : Key Issues with Props Drilling:
  • Data moves between many components without a clear function
  • Components become non-reusable
  • Difficult to refactor
  • Too many defineProps

4 Effective Solutions to Avoid Props Drilling

Here are 4 effective solutions to avoid props drilling in Vue 3:

1. Provide & Inject (Built-in Vue)

Vue provides a built-in feature called provide and inject that allows parent components to provide data that can be injected by any descendant component, regardless of the depth of the component tree. code example : Advantages:
  • No additional libraries required
  • Suitable for global configuration (theme, user authentication, language)
  • Cleaner than props drilling
Disadvantages
  • Difficult to trace data sources
  • Not suitable for complex states

2. Vuex or Pinia (State Management Libraries)

For medium to large applications, Vuex or Pinia is the best solution. code example using Pinia: Advantages:
  • Centralized global state
  • Easy to debug
  • Suitable for auth, cart, role, permission
  • Ideal for large projects

3. Composition API with Composables

Composable is suitable for logic reuse without having to create global state. code example : Advantages:
  • No need for global store
  • Suitable for reusable logic
  • More flexible

4. Using slot

Slots are often used for UI composition. code example : Advantages:
  • Good for UI composition
  • Data is only passed to components that need it
  • Cleaner component structure

Can Props Drilling Still Be Used?

Props drilling is not inherently bad. In small applications or simple component structures, props drilling can be straight forward and easy to understand. However, as the application grows, it is advisable to consider the above solutions to maintain code quality, scalability, and maintainability.

Conclusion

Props drilling is a common problem in larger Vue 3 application development. Fortunately, Vue 3 provides many elegant solutions to overcome this:
  • Use provide & inject for global configuration
  • Use Pinia for complex state
  • Use composables for reusable logic
  • Use slots for UI composition
With a clean state structure, your application will be:
  • Easier to maintain
  • More scalable
  • More comfortable to develop in the long term

Gilang Fatahilah

— Gilang

Thanks for reading this far. Come back whenever there's a new page.

Share this entry:

Keep reading

  1. Entry No.02December 5, 2025Vue, Javascript, Front-end

    Ref vs Reactive, which one should you use?

    A practical explanation of the differences between ref and reactive in Vue 3, complete with code examples, common pitfalls, and best practices for their use.

    5 min read →
  2. Entry No.05January 25, 2026Personal Thoughts, Linux

    I'm Switching to Linux: Was Fedora the Right Choice?

    After one month of switching from Windows to Fedora Linux, I share my honest experience as a developer. From better performance and a cleaner workflow to Docker, GNOME, and daily dev tools, this article explores whether Fedora is really the right choice, and the trade-offs that come with it.

    4 min read →
App.vue
└─ Parent.vue
  └─ Child.vue
    └─ GrandChild.vue
vue
<!-- App.vue -->
<Parent :user="user" />

<!-- Parent.vue -->
<Child :user="user" />

<!-- Child.vue -->
<GrandChild :user="user" />
<script setup>
import { provide } from "vue"

const user = {
name: "Haerin",
role: "Admin"
}

provide("user", user)
</script>

<template>
<Parent />
</template>
import { defineStore } from "pinia"

export const useUserStore = defineStore("user", {
state: () => ({
  user: {
    name: "Haerin",
    role: "Admin"
  }
})
})
import { ref } from "vue"

const user = ref({
name: "Haerin",
role: "Admin"
})

export function useUser() {
return { user }
}
<script setup>
const user = {
name: "Haerin",
role: "Admin"
}
</script>

<template>
<slot :user="user" />
</template>