KoderSolutionKoderSolution LogoKoderSolution Logo
HomeArticlesTutorialsToolsRun CodeForumAI Lab
🖖

Vue

Topic Hub & Articles

Vue Intro

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Get Started

10 min

Vue Directives

10 min

Vue Events

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Forms

10 min

Vue Components

10 min

Vue Props

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Methods

10 min

Vue Computed Properties

10 min

Vue Watchers

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Class and Style Bindings

10 min

Vue Conditional Rendering

10 min

Vue List Rendering

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Template Syntax

10 min

Vue Teleport

10 min

Vue Suspense

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Transitions

10 min

Vue Mixins

10 min

Vue Custom Directives

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Plugins

10 min

Vue Slots

10 min

Vue Provide / Inject

10 min

Recap Quiz

Gated

Milestone Assessment

Vue Dynamic Components

10 min

Vue Async Components

10 min

Composition API Intro

10 min

Recap Quiz

Gated

Milestone Assessment

ref vs reactive

10 min

Lifecycle Hooks

10 min

Dependency Injection

10 min

Recap Quiz

Gated

Milestone Assessment

Computed and Watch

10 min

Template Refs

10 min

Composable Functions

10 min

Script Setup

10 min

Progress
0%

0 / 32 Lessons

KoderSolutionKoderSolution LogoKoderSolution Logo

The world’s most advanced technical ecosystem for modern software engineers. Learn, build, and grow with next-generation developer tools and resources.

Facebook PageX (Twitter) ProfileYouTube ChannelContact Support

Engineering Newsletter

Subscribe for weekly software engineering tutorials, architecture guides, and developer tool updates.

Platforms

  • Technical Articles
  • Interactive Tutorials
  • AI Coding Lab
  • Developer Forum
  • Developer Tools

Pages

  • About Us
  • Contact Us
  • Privacy Policy
  • Terms of Service
  • Refund Policy
  • Disclaimer
  • Advertisement

Popular Topics

  • PHP
  • Laravel
  • Python
  • React.Js
  • MySQL
© 2026 KoderSolutionAll Rights Reserved
Developed Bymaksudur.dev
VueVue Tutorial
Lesson

Vue Plugins

10 min reading
Free Course

Vue Plugins: Extending Application Functionality with app.use()

Vue plugins are self-contained modules that add app-wide features to a Vue application. Popular tools like Vue Router, Pinia, and i18n libraries all ship as plugins installed via app.use().

A plugin can register global components, add custom directives, attach properties to app.config.globalProperties, or supply dependencies with app.provide(). Writing your own plugin keeps cross-cutting setup code clean and reusable across projects.

flowchart TD
    Plugin["Plugin Object { install(app, options) }"] --> Use["app.use(plugin, options)"]
    Use --> Components["Global Components and Directives"]
    Use --> Provide["app.provide() Dependencies"]

Structure of a Vue 3 Plugin

A plugin is either an object exposing an install(app, options) method or an install function directly. Vue calls install once and passes the application instance plus any configuration options.

Practical Plugin Example

Here is a lightweight translation plugin in src/plugins/i18n.js that both provides an injection value and attaches a $t helper.

// src/plugins/i18n.js
export default {
  install(app, options = {}) {
    const dictionary = options.dictionary || {};

    const translate = (key) => {
      return (
        key.split('.').reduce((acc, part) => (acc ? acc[part] : null), dictionary) ||
        key
      );
    };

    app.config.globalProperties.$t = translate;
    app.provide('i18n', { translate });
  }
};

Register the plugin in src/main.js before calling app.mount('#app').

// src/main.js
import { createApp } from 'vue';
import App from './App.vue';
import i18nPlugin from './plugins/i18n';

const app = createApp(App);

app.use(i18nPlugin, {
  dictionary: {
    greetings: {
      welcome: 'Welcome to Vue 3!'
    }
  }
});

app.mount('#app');

Inside App.vue, templates can call $t, while <script setup> can inject i18n directly.

<script setup>
import { inject } from 'vue';

const { translate } = inject('i18n');
</script>

<template>
  <section>
    <h2>{{ $t('greetings.welcome') }}</h2>
    <p>{{ translate('greetings.welcome') }}</p>
  </section>
</template>

Common Mistakes

  • Calling app.use() After app.mount(): Always register every plugin before app.mount('#app'). Calling app.use() afterward misses components that already mounted.
  • Overusing globalProperties: Attaching too many helpers to app.config.globalProperties hides dependencies and weakens TypeScript inference. Prefer app.provide() paired with inject() inside <script setup>.
  • Mutating Options Without Defaults: Always default options = {} inside install(app, options) so calling app.use(myPlugin) without arguments never throws a TypeError.

Frequently Asked Questions

What happens if app.use() is called twice with the same plugin?

Vue tracks installed plugins on each app instance and ignores duplicate app.use(plugin) calls automatically.

Can I access this.$t inside <script setup>?

No. <script setup> has no this context. Use app.provide() inside your plugin and inject() inside <script setup> instead.

When should I build a plugin instead of a composable?

Build a plugin when a library needs app-level setup once during startup, such as registering routes, global stores, or global components.

Save Your Progress

Unlock Your
Full Potential.

Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.

Quick Access With

Enterprise-Grade Security Protocol

Related Developer Tools & Topic Hub

Vue Topic Hub
JSON Formatter
Validate and format JSON payloads
HTML Formatter
Format HTML templates
CSS Formatter
Clean and format stylesheets
All Vue Articles
Deep-dive guides, tips & discussions
PreviousVue Custom Directives
Continue JourneyNext: Vue Slots

Stuck on this lesson?

Join our community of senior developers.

Ask in Forum