# Why is it necessary to import Ionic components?

**URL:** <https://forum.ionicframework.com/t/why-is-it-necessary-to-import-ionic-components/200885>\
**Category:** Ionic Vue\
**Created:** [December 8, 2020, 11:37am UTC](https://forum.ionicframework.com/t/why-is-it-necessary-to-import-ionic-components/200885 "2020-12-08T11:37:52Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![baselmx](https://avatars.discourse-cdn.com/v4/letter/b/ba8739/32.png) [@baselmx](https://forum.ionicframework.com/u/baselmx)\
**Post date:** [December 8, 2020, 11:37am UTC](https://forum.ionicframework.com/t/why-is-it-necessary-to-import-ionic-components/200885/1 "2020-12-08T11:37:52Z")

</div>

Looking at Quasar, Vuetify, and Nuxt, Ionic is the only framework that requires you to import the tags/components that you are going to use in a view. Why is that, and is there a way of auto-importing the components like other frameworks do? The Ionic way requires quite a lot of additional typing. When you add or remove tags in your view, you have to remember to add/remove them in three places (!) in your view: In the template, in the import, and in the components line. That makes the whole thing a bit inflexible. Here’s an example:

**Ionic** :

```auto
<template>
  <ion-button>Yes</ion-button>
</template>

<script>
import { IonButton } from '@ionic/vue';

export default {
  components: {
    IonButton
  }
});
</script>

```

**Vuetify:**

```auto
<template>
  <v-btn>Yes</v-btn>
</template>

```

**Quasar:**

```auto
<template>
  <q-btn label="Yes" />
</template>

```

**Nuxt:**

```auto
<template>
  <NuxtLink to="/">Home</NuxtLink>
</template>

```

---

<div class="post-metadata">

**Author:** ![ldebeasi](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/ldebeasi/32/147501_2.png) [@ldebeasi](https://forum.ionicframework.com/u/ldebeasi)\
**Post date:** [December 8, 2020, 2:59pm UTC](https://forum.ionicframework.com/t/why-is-it-necessary-to-import-ionic-components/200885/2 "2020-12-08T14:59:24Z")

</div>

The Ionic Vue Quickstart Guide goes over this: [Vue QuickStart Global Component for Generating Ionic Vue Apps](https://ionicframework.com/docs/vue/quickstart#optimizing-your-build)

Here is the relevant text:

> By default, Ionic Framework components are registered locally. With local registration, these components are imported and provided to each Vue component you want to use them in. This is the recommended approach as it allows lazy loading and treeshaking to work properly with Ionic Framework components.

If you prefer not to use local component registration, you can register the components globally once and then use it just as you would in Vuetify or Quasar:

```js
import { IonContent, IonicVue, IonPage } from '@ionic/vue';

const app = createApp(App)
  .use(IonicVue)
  .use(router);

app.component('ion-content', IonContent);
app.component('ion-page', IonPage);

```

---

<div class="post-metadata">

**Author:** ![mirko77](https://sea1.discourse-cdn.com/ionicframework/user_avatar/forum.ionicframework.com/mirko77/32/137216_2.png) [@mirko77](https://forum.ionicframework.com/u/mirko77)\
**Post date:** [May 24, 2024, 12:35pm UTC](https://forum.ionicframework.com/t/why-is-it-necessary-to-import-ionic-components/200885/3 "2024-05-24T12:35:29Z")

</div>

Late to the party but for anyone who needs it, in your `main.js` file

```auto
import * as IonComponents from '@ionic/vue';
import App from '@/App.vue';

export const app = createApp(App);

//register all Ionic components globally
  Object.keys(IonComponents).forEach((key) => {
    if (/^Ion[A-Z]\w+$/.test(key)) {
      app.component(key, IonComponents[key]);
    }
  });

 app.mount('#app');

```
