---
title: Avoid Component Naming Conflicts Between Global and Local
impact: HIGH
impactDescription: Naming conflicts cause unexpected component rendering and hard-to-debug issues
type: gotcha
tags: [vue3, component-registration, naming-conflicts, global-local, debugging]
---
# Avoid Component Naming Conflicts Between Global and Local
**Impact: HIGH** - When a global component and a local component have the same name (or resolve to the same name due to casing differences), unexpected behavior occurs. The precedence rules can be confusing, and the wrong component may render silently without any error. This is particularly problematic when using third-party component libraries.
## Task Checklist
- [ ] Use unique, prefixed names for global components (e.g., `BaseButton`, `AppHeader`)
- [ ] Check for naming conflicts when adding global components
- [ ] Explicitly alias local components if there's potential conflict
- [ ] When overriding third-party components, document and test thoroughly
**Incorrect:**
```javascript
// main.js
import { createApp } from 'vue'
import Button from './components/Button.vue'
const app = createApp(App)
app.component('Button', Button) // Global Button
```
```vue
```
```vue
Click
```
**Correct:**
```javascript
// main.js - use prefixes for global components
import { createApp } from 'vue'
import BaseButton from './components/BaseButton.vue'
import BaseIcon from './components/BaseIcon.vue'
const app = createApp(App)
app.component('BaseButton', BaseButton)
app.component('BaseIcon', BaseIcon)
```
```vue
Generic buttonSubmit form
```
## Explicit Aliasing for Clarity
When you intentionally want to override or have similar names, use explicit aliasing:
```vue
Local version
```
```vue
```
## Resolution Order
Understanding Vue's component resolution order helps debug issues:
1. **Local registration** takes precedence over global
2. **Exact case match** takes precedence over case-insensitive match
3. Self-referencing component name (file name) has lowest priority
```vue
```
## Third-Party Library Conflicts
```vue
Ant DesignElement Plus
```
## Naming Convention Strategy
| Component Type | Naming Pattern | Example |
|----------------|---------------|---------|
| Base/Global | `Base*` or `App*` prefix | `BaseButton`, `AppHeader` |
| Domain-specific | Domain prefix | `UserCard`, `ProductList` |
| Page components | `*Page` or `*View` suffix | `HomePage`, `UserView` |
| Layout components | `*Layout` suffix | `DefaultLayout`, `AdminLayout` |
## Reference
- [Vue.js Component Registration](https://vuejs.org/guide/components/registration.html)
- [GitHub Issue: Global component naming conflicts](https://github.com/vuejs/vue/issues/4434)