Throughout this module you have been accumulating tools that let components communicate: props and events, v-model, slots, refs with defineExpose... Each one solves a specific problem, and choosing the right one is one of the most frequent design decisions in a Vue application. In this lesson we will arrange them all on a map, see how two sibling components (with no direct relationship) communicate, and study in depth the channel we are still missing: provide/inject, which lets a component offer data to all its descendants without passing it from hand to hand. We will also look at two alternatives you will come across in real code, the global event bus and shared state in a module, and at why their limitations lead to the state management libraries of module 5. In Colmena, App.vue will provide the member's session, which the header and the booking form will obtain with inject.

Contents

  1. The map of component communication
  2. Siblings: lifting state up to the common parent
  3. The problem of passing props from hand to hand
  4. provide and inject
  5. Providing reactive values
  6. readonly and functions for making changes
  7. Symbol keys in a keys file
  8. Default values in inject
  9. app.provide: data for the whole application
  10. The global event bus: why to avoid it
  11. Shared state in a JavaScript module and its limits
  12. Case study: the member's session

  1. The map of component communication

Channel Direction Reach Use it to... In Colmena
Props Parent → child Direct child Pass the data the child needs to render itself room in RoomCard
Events (emit) Child → parent Direct parent Report that something has happened or request a change book, create
v-model Two-way (prop + event) Parent ↔ direct child Controls that edit a piece of the parent's data RoomFilters, TextField
Slots Parent → child (markup); scoped, child → parent (data) Direct child Let the parent decide part of what is rendered #room in RoomList, #actions
Refs + defineExpose Parent → child (calls) Direct child Imperative actions: focusing, resetting BookingForm's reset()
provide/inject Ancestor → any descendant The whole subtree Context data needed by many components at different depths The member's session (this lesson)
Global state (store) Anyone ↔ anyone The whole application State shared by distant parts of the application Pinia, in module 5
flowchart TD
    A["App.vue"]
    A -->|"props"| H["Child"]
    H -.->|"events"| A
    A <-->|"v-model"| C["Control (RoomFilters)"]
    A -->|"slots"| S["Container (BasePanel)"]
    A -->|"ref + exposed method"| F["BookingForm"]
    A ==>|"provide"| X["..."]
    X ==> N["Distant grandchild: inject"]

A rule for choosing: start with the simplest and most explicit channel (props and events) and only move up a level when it starts to hurt. Explicit channels can be read in the template: you know where each piece of data comes from and where each notification goes.

  1. Siblings: lifting state up to the common parent

Two sibling components cannot communicate directly: neither is the parent of the other. The standard solution is lifting state up: the shared data moves to the closest common ancestor, which passes it to one of them as a prop and receives from the other the events that modify it.

You have been doing this throughout the module without naming it. The catalogue views and BookingForm are siblings inside App.vue, and they coordinate like this when the user clicks "Book" on a card:

sequenceDiagram
    participant V as Catalogue view
    participant A as App.vue (common state)
    participant F as BookingForm
    V->>A: emit('book', { roomId: 'nectar', attendees: 4 })
    A->>A: selectedRoomId = 'nectar'<br/>requestedAttendees = 4
    A->>F: props room-id = 'nectar', attendees = 4
    F->>F: watch: updates form
    F->>A: emit('create', booking)
    A->>A: bookings.push(booking)
    A->>F: reset()
  • Neither sibling knows that the other exists: the view only emits book and the form only receives props.
  • App is the single source of truth for the selected room and for the bookings. If tomorrow we add a third component that needs the selected room (the spec sheet panel already does), it is enough to pass it along.

Lifting state up works very well as long as the common ancestor is close by. The problem appears when it is not.

  1. The problem of passing props from hand to hand

Imagine a piece of data that many components need, at different depths: the signed-in member. The header needs it (to greet them), the booking form needs it (to fill in the name) and, in the future, the room card (to show the price according to the plan) or the user dashboard. With props, every intermediate component would have to receive it just to pass it on to its child, even though it does not use it itself:

flowchart TD
    A["App.vue<br/>(session)"] -->|"session prop"| V["GridView<br/>(does not use it)"]
    V -->|"session prop"| L["RoomList<br/>(does not use it)"]
    L -->|"session prop"| T["RoomCard<br/>(uses it)"]

This is known as prop drilling. The intermediate components fill up with props that are none of their business, any change to the data forces you to touch the whole chain and generic components such as RoomList stop being generic. The problem will get worse in module 4: with the router, the form will live inside a route view (BookingView) rendered by <RouterView>, and App will no longer be able to pass props to it directly.

  1. provide and inject

provide and inject solve the drilling: a component provides a value with a key, and any descendant, at any depth, injects it with that same key, without the intermediate components getting involved.

<!-- Ancestor: App.vue -->
<script setup>
import { provide } from 'vue'

provide('centreName', 'Coworking Colmena')
</script>
<!-- Any descendant, at any depth -->
<script setup>
import { inject } from 'vue'

const centreName = inject('centreName')
</script>

<template>
  <p>Welcome to {{ centreName }}</p>
</template>
flowchart TD
    A["App.vue<br/>provide('session', ...)"] --> V["GridView"]
    V --> L["RoomList"]
    L --> T["RoomCard<br/>inject('session')"]
    A --> C["AppHeader<br/>inject('session')"]
    A -. "arrives directly" .-> T

How it works:

  • provide(key, value) and inject(key) are called at the top level of <script setup> (synchronously), just like lifecycle hooks.
  • inject looks for the key by going up the tree and uses the closest provider. An intermediate component can provide the same key again for its subtree, overriding it.
  • A component does not inject what it provides itself: provide affects its descendants.
  • If no ancestor provides the key, inject returns undefined and Vue warns you in the console (unless you give a default value, section 8).
  • In the Options API, you use the provide() { return { ... } } and inject: ['key'] options.

The trade-off is that the dependency is implicit: looking at the parent's template, you cannot see what data a descendant receives by injection. That is why provide/inject is reserved for context data: session, configuration, visual theme, language, shared services. For everything else, props are still better.

  1. Providing reactive values

If you provide an ordinary value, the descendants receive a fixed copy. For them to react to changes, provide a ref or a reactive: what travels is the reactive object itself, and everyone who injects it shares the same one.

// Ancestor
const session = reactive({ name: 'Laura Gómez', plan: 'flexible' })
provide('session', session)
// Descendant
const session = inject('session')
// In the template: {{ session.name }} updates if the ancestor changes it

One subtlety: if you provide a ref, the descendant receives the ref and must use .value in the script (in the template it is unwrapped, as always). With reactive, you access the properties directly.

  1. readonly and functions for making changes

With the previous example, any descendant could do session.plan = 'business' and change App's state without anyone knowing. It is the same objection we raised in 03-02 to mutating props, multiplied by every descendant.

The recommended pattern is the one we anticipated in Reactivity: ref and reactive when we introduced readonly: the provider keeps the original, exposes a read-only version and provides functions for the permitted changes:

// Ancestor
import { provide, reactive, readonly } from 'vue'

const session = reactive({ name: 'Laura Gómez', plan: 'flexible', role: 'member' })

function changePlan(plan) {
  // The only place where it is modified: here we can validate, log, notify the server...
  if (['flexible', 'fixed', 'business'].includes(plan)) {
    session.plan = plan
  }
}

provide('session', {
  session: readonly(session),
  changePlan
})
// Descendant
const { session, changePlan } = inject('session')

session.plan = 'business' // ⚠️ warning: the object is read-only, it has no effect
changePlan('business')    // ✅ the permitted channel

The descendant still sees the changes (the readonly version is reactive), but it can only modify the state through the channels the provider has decided on. It is the equivalent, for injection, of "props down, events up".

  1. Symbol keys in a keys file

String keys ('session') work, but in a large application, or if you use libraries that also provide values, two identical keys would collide silently. The recommended practice is to use symbols, which are unique by definition, and to gather them in a file:

// src/keys.js
export const SESSION_KEY = Symbol('session')
export const CONFIG_KEY = Symbol('config')
import { SESSION_KEY } from '@/keys.js'

provide(SESSION_KEY, { ... }) // in the provider
inject(SESSION_KEY)           // in the consumer
  • Symbol('session') creates a unique value; the text in brackets is just a description for debugging.
  • By importing the key from the same file, provider and consumer use the same symbol. A typo becomes an import error, which the editor detects instantly, instead of a silent undefined.
  • The keys file is also the index of everything that is injected in the application.

  1. Default values in inject

inject accepts a second parameter: the default value if no ancestor provides the key. It is useful for making a component also work outside its usual context (in a test, in another application):

// Simple default value
const config = inject(CONFIG_KEY, { openingHour: 8, closingHour: 20 })

// A default value that is expensive or must be new on every use: a factory
// (the third argument, true, indicates that the second is a function to be called)
const context = inject(SESSION_KEY, () => ({ session: reactive({ name: '', role: 'manager' }) }), true)

If a component cannot work without the value, it is better not to give a default value and to let the console warning reveal the problem.

  1. app.provide: data for the whole application

As well as components, the application instance can provide values, as you saw in the table of methods in 01-04. Whatever is provided with app.provide is available in every component, App included:

// src/main.js
import { createApp } from 'vue'
import App from './App.vue'
import { CONFIG_KEY } from './keys.js'
import './assets/main.css'

const app = createApp(App)

app.config.errorHandler = (error, instance, info) => {
  // ... no changes ...
}

app.provide(CONFIG_KEY, {
  centreName: 'Coworking Colmena',
  openingHour: 8,
  closingHour: 20
})

app.mount('#app')

It is the right place for the application's fixed configuration. It is also the mechanism that plugins use to offer their services to every component, as you will see in Creating a Vue.js Plugin.

  1. The global event bus: why to avoid it

In Vue 2 it was very common to create an event bus: a global object on which any component could emit events and any other could listen to them. Vue 3 removed the methods that made this possible ($on, $off, $once), and anyone who wants one today turns to minimal libraries such as mitt:

// src/bus.js (just as an example: we will NOT use it in Colmena)
import mitt from 'mitt'
export const bus = mitt()
// Some component emits...
bus.emit('bookingCreated', booking)

// ...and another, anywhere in the tree, listens
import { onUnmounted } from 'vue'

function onBookingCreated(booking) { /* ... */ }
bus.on('bookingCreated', onBookingCreated)
onUnmounted(() => bus.off('bookingCreated', onBookingCreated)) // forget this and you have a memory leak

It seems convenient, but it has serious problems:

Problem Consequence
Invisible flow Reading a component, you do not know who reacts to its events or where the ones it listens to come from. Debugging turns into searching for strings throughout the project
Memory leaks Every on without its off leaves a live listener that holds on to the destroyed component and keeps running
Order and timing If the receiver has not yet been mounted when the event is emitted, the event is lost
No state An event is a one-off notification; the data it communicates is not stored anywhere
No tooling Vue DevTools does not show the events of an external bus

When might it make sense? In limited cases: ephemeral notifications that are genuinely global (showing a notification, logging an analytics event), or communication with non-Vue code or between several applications mounted on the same page. Even then, providing a function with provide (for example, notify(message)) is often enough, and it keeps a single, known receiver.

  1. Shared state in a JavaScript module and its limits

In 03-01 we saw that whatever is declared in a JavaScript module is unique and shared by everyone who imports it. Combined with reactive, that gives a very simple form of global state:

// src/state/sharedBookings.js (example: we will NOT adopt it)
import { reactive, readonly } from 'vue'

const state = reactive({ bookings: [] })

export const sharedBookings = readonly(state)

export function addBooking(booking) {
  state.bookings.push(booking)
}
// Any component, with no provide or props
import { sharedBookings, addBooking } from '@/state/sharedBookings.js'

It works, and for a small application it may be enough. But it has limits that become noticeable as soon as the application grows:

Limit Why it matters
No debugging tools Vue DevTools does not show this state as such, nor a timeline of who changed it and when
Dangerous with SSR On the server, a module is loaded once for all requests: one user's state would leak to another (09-06)
Anyone can mutate it If the original reactive is exported (or someone forgets the readonly), there is no control at all over the changes
No structure Each module invents its own way of organising state, derived values and asynchronous actions
Testing The state persists between tests because the module is unique; it has to be reset by hand

These shortcomings are exactly what state management libraries cover: a centralised store with a defined structure (state, derived values, actions), integration with DevTools, and support for SSR and testing. Vue has two: Vuex, the historical one, still present in a great many projects, and Pinia, the one recommended today. We will study them in module 5, where Colmena's data will move into the rooms, bookings and session stores.

  1. Case study: the member's session

Colmena needs to know who is using the application. There is no sign-in yet (it will arrive with LoginView in module 4), so App.vue will create a temporary session following the course's data model and provide it to its descendants.

12.1 The keys file and the configuration

Create src/keys.js with the two keys from section 7 and add the app.provide(CONFIG_KEY, ...) from section 9 to src/main.js.

12.2 App.vue provides the session

In the script of App.vue, add provide and readonly to the vue import and:

import { SESSION_KEY } from './keys.js'

// --- Member's session (temporary: it will come from signing in in module 4) ---
const session = reactive({
  name: 'Laura Gómez',
  email: '[email protected]',
  plan: 'flexible', // 'flexible' | 'fixed' | 'business'
  role: 'member' // 'member' | 'manager'
})

// Temporary, for trying out both roles without signing in
function toggleRole() {
  session.role = session.role === 'member' ? 'manager' : 'member'
}

provide(SESSION_KEY, {
  session: readonly(session),
  toggleRole
})
  • session follows the { name, email, plan, role } model. The .example domain is reserved for examples: it will never correspond to a real email address.
  • It is provided as readonly, with toggleRole as the only way of changing it.
  • App is still the owner: if in future the session comes from the API, only this block will change.

12.3 AppHeader shows the member

In AppHeader.vue:

import { ref, inject } from 'vue' // add inject to the existing import
import { SESSION_KEY } from '@/keys.js'

const { session, toggleRole } = inject(SESSION_KEY)
<!-- In the template, inside .header__reception, before the clock -->
<p class="header__session">
  {{ session.name }} · {{ session.plan }} plan
  <span v-if="session.role === 'manager'" class="header__role">manager</span>
</p>
<BaseButton variant="secondary" @click="toggleRole">
  View as {{ session.role === 'member' ? 'manager' : 'member' }}
</BaseButton>
/* In the <style scoped> of AppHeader.vue */
.header__role {
  padding: 0.1rem 0.5rem;
  border-radius: 999px;
  background: var(--color-text);
  color: white;
  font-size: 0.8rem;
}

BaseButton was already imported in the header from Slots onwards. Notice that AppHeader does not receive any new props: App does not have to do anything in its template for the header to know who the member is.

12.4 BookingForm fills in the member

The business rules are: a member books for themselves, so the name is filled in with the one from the session and cannot be changed; a manager books on behalf of others, so the field is left free. In addition, the form's times will come from the centre's configuration instead of being written into the code.

In the script of BookingForm.vue, add inject to the vue import and:

import { SESSION_KEY, CONFIG_KEY } from '@/keys.js'

// With a default value: the form also works without a session (e.g. in tests),
// treating the user as a manager so that they can type any name
const { session } = inject(
  SESSION_KEY,
  () => ({ session: reactive({ name: '', role: 'manager' }) }),
  true
)
const { openingHour, closingHour } = inject(CONFIG_KEY, { openingHour: 8, closingHour: 20 })

const isManager = computed(() => session.role === 'manager')

// Replaces the old fixed definition of dayHours
const dayHours = Array.from(
  { length: closingHour - openingHour + 1 },
  (_, i) => `${String(openingHour + i).padStart(2, '0')}:00`
)

These lines must go before const form = reactive(createEmptyForm()), because createEmptyForm now uses isManager and runs as soon as the form is created:

function createEmptyForm() {
  return {
    roomId,
    date: '',
    startTime: '10:00',
    endTime: '12:00',
    member: isManager.value ? '' : session.name, // the member books for themselves
    attendees,
    status: 'confirmed',
    extraEquipment: [],
    notes: '',
    acceptsRules: false
  }
}

// If the role changes, the member field adapts
watch(isManager, (manager) => {
  form.member = manager ? '' : session.name
})

And in the template, the member's TextField:

<TextField
  ref="member-field"
  v-model.trim="form.member"
  :label="isManager ? 'Member name' : 'Booking in the name of'"
  autocomplete="name"
  placeholder="e.g. Laura Gómez"
  :readonly="!isManager"
  :error="visibleError('member')"
  @blur="markTouched('member')"
/>
  • inject with a factory (third argument true): if nobody provides the session, a new context is created with an anonymous manager. That way BookingForm can still be used in isolation, something you will appreciate in module 8 when testing it.
  • dayHours is generated from the configuration: from 8 to 20 you get the same 13 hours as before, but if the centre changes its opening hours, the change is made in main.js.
  • :readonly="!isManager" reaches the <input> because TextField forwards its attributes (we prepared this in 03-05). A readonly field, unlike a disabled one, can be focused and read by the screen reader, and its value is still part of the form.
  • The isManager watcher keeps the form consistent when the role changes.

12.5 The final state of App.vue

At the start of the module, App.vue contained the whole application. This is its <script setup> at the end of it (unchanged function bodies are omitted):

import { ref, reactive, readonly, computed, watch, watchEffect, onWatcherCleanup,
  provide, useTemplateRef, defineAsyncComponent } from 'vue'
import AppHeader from './components/AppHeader.vue'
import ShortcutsHelp from './components/ShortcutsHelp.vue'
import RoomFilters from './components/RoomFilters.vue'
import BookingForm from './components/BookingForm.vue'
import StatusBadge from './components/StatusBadge.vue'
import BaseButton from './components/base/BaseButton.vue'
import BasePanel from './components/base/BasePanel.vue'
import GridView from './components/catalog/GridView.vue'
import TableView from './components/catalog/TableView.vue'
import MapLoading from './components/catalog/MapLoading.vue'
import MapError from './components/catalog/MapError.vue'
import { rooms } from './data/rooms.js'
import { fetchRooms } from './api/rooms.js'
import { SESSION_KEY } from './keys.js'

const BuildingMap = defineAsyncComponent({ /* 03-06 */ })

// Session: session, toggleRole and provide(SESSION_KEY, ...)             (03-07)
// Catalogue: floorFilter, catalog, loading, error, loadRooms,
//   watch(floorFilter), reloadRooms, freeRooms                           (module 2)
// Filters: minCapacity, requiredEquipment, sort, search,
//   normalize, matchesSearch, catalogEquipment,
//   roomsWithCapacity, visibleRooms, clearFilters, hasResults
// View: views, currentView                                              (03-06)
// Selection: selectedRoomId, selectedRoom, selectRoom,
//   specSheet, the title's watchEffect
// Bookings: requestedAttendees, bookings, bookingForm,
//   prepareBooking, recordBooking, roomNameById
// Utilities: euroFormatter, formatPrice

And its template, which now reads like an index of the page:

<template>
  <AppHeader />

  <main class="content">
    <ShortcutsHelp />

    <section class="catalog">
      <h2>Catalogue</h2>
      <RoomFilters v-model:floor="floorFilter" ... :equipment-options="catalogEquipment" />
      <!-- states: loading / error / empty / no results / free rooms + view switcher -->
      <KeepAlive :max="3">
        <component :is="views[currentView].component" v-if="hasResults" ... />
      </KeepAlive>
    </section>

    <BasePanel><!-- selected room: header, spec sheet and footer --></BasePanel>

    <section class="booking">
      <h2>New booking</h2>
      <BookingForm ref="booking-form" ... @create="recordBooking" />
      <BasePanel><!-- bookings created in this session --></BasePanel>
    </section>
  </main>
</template>

App.vue no longer renders details: it keeps the shared state and coordinates. Each responsibility has its own component, and the tree is the one we drew in 03-01, with one more layer: the catalogue views we added in 03-06, between App and RoomList.

12.6 Try it

  1. The header shows "Laura Gómez · flexible plan". In the form, the "Booking in the name of" field appears filled in with Laura Gómez and cannot be edited, but it can be focused.
  2. Click "View as manager": the header shows the "manager" label, the field is renamed "Member name", is emptied and can be edited. Go back to "View as member".
  3. In Vue DevTools, select BookingForm: in its injected section you will see the session and the configuration, without them appearing as props.
  4. Try modifying the session from a descendant: temporarily add session.plan = 'business' to the script of AppHeader. The console will show a warning that the object is read-only, and the plan will not change. Remove it.
  5. Change closingHour to 18 in main.js: the time drop-downs now end at 18:00. Set it back to 20.

Common Mistakes and Tips

  • Providing a non-reactive value and expecting it to update. Provide a ref or a reactive.
  • Providing the state without readonly. Any descendant will be able to modify it without control; provide functions for the changes.
  • Calling inject outside the top level of the script (inside an event handler, after an await). It must be called while the component is being created.
  • Using strings as keys in large projects. They collide silently; use a Symbol in a keys file.
  • Using provide/inject for everything. Implicit dependencies make components harder to understand. Reserve it for context data.
  • Setting up an event bus to avoid passing props. The flow becomes invisible and memory leaks appear.
  • Turning a module with a reactive into the global state of a growing application. Its limits (DevTools, SSR, control over changes) are reached quickly; that is what stores are for.
  • Tip: before choosing a communication channel, draw the tree and mark where the data lives and who needs it. If they are one level apart, props and events; if they are siblings, lift the state up; if there are many levels in between and it is context data, provide/inject; if distant parts need it and it changes a lot, a store.

Exercises

Exercise 1. Make RoomCard inject the session and, if the member's plan is 'business', show the text "Included in your company's pass" below the price. Check in DevTools that neither GridView nor RoomList has had to change. What default value would you give inject in this component, and why?

Exercise 2. State which communication channel you would use in each case and justify it in one sentence: (a) BookingForm must tell App that the user has started typing, so that "Booking in progress" is shown in the header; (b) every component must know the interface language; (c) BasePanel must show a different button in the footer depending on where it is used; (d) App must make TableView sort itself by name again.

Exercise 3. Create a notification system without an event bus: App.vue provides, with the NOTIFICATIONS_KEY key, a notify(message) function that adds the message to a notifications list (each one with an id and a text) and removes it after 4 seconds. App renders the list in a <div role="status"> fixed in one corner. BookingForm must call notify when it creates a booking ("Booking created in the Néctar Room for 2026-11-03").

Solutions

Solution 1.

// RoomCard.vue
import { inject } from 'vue'
import { SESSION_KEY } from '@/keys.js'

const { session } = inject(SESSION_KEY, { session: { plan: 'flexible' } })
<p>Floor {{ room.floor }} · {{ formatPrice(room.hourlyPrice) }}/h</p>
<p v-if="session.plan === 'business'" class="card__pass">Included in your company's pass</p>

Neither GridView nor RoomList changes: the session arrives directly from App. As the default value, a session with an ordinary plan ('flexible'): the card is a presentational component that must be renderable in any context (a test, another page), and in the absence of a session the sensible thing is to show the price without any discounts. To try it out, temporarily change the plan in App.vue's session.

Solution 2.

  • (a) An event from BookingForm (for example, edit) that App listens to and stores in a ref, and a prop from App to AppHeader. They are siblings: the state is lifted up to the common parent. (A valid alternative: since the header already injects the session, App could provide that state as well; but an event and a prop are more explicit.)
  • (b) app.provide (or the internationalization plugin in 07-03, which does this under the hood): it is context data that every component needs.
  • (c) A slot (#footer): it is content that each parent decides, not data.
  • (d) An exposed method with defineExpose (for example, resetSort()) and a ref from App: it is a one-off action on a child's internal state. If App also needed to know the sort order, the right thing would be to lift that state up and use v-model:sort.

Solution 3.

// src/keys.js
export const NOTIFICATIONS_KEY = Symbol('notifications')
// App.vue
import { NOTIFICATIONS_KEY } from './keys.js'

const notifications = ref([])

function notify(text) {
  const id = crypto.randomUUID()
  notifications.value.push({ id, text })
  setTimeout(() => {
    notifications.value = notifications.value.filter((n) => n.id !== id)
  }, 4000)
}

provide(NOTIFICATIONS_KEY, notify)
<!-- App.vue, at the end of the template -->
<div class="notifications" role="status" aria-live="polite">
  <p v-for="notification in notifications" :key="notification.id" class="note">
    {{ notification.text }}
  </p>
</div>
.notifications {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: grid;
  gap: 0.5rem;
}
// BookingForm.vue
import { NOTIFICATIONS_KEY } from '@/keys.js'

const notify = inject(NOTIFICATIONS_KEY, () => {}) // no provider: it does nothing

// In submitBooking, after emit('create', booking):
notify(`Booking created in the ${formRoom.value.name} for ${booking.date}`)

Unlike a bus, there is a single, known receiver (App), the function can be located by looking up the key in the keys file and there are no listeners to unsubscribe. The default value () => {} allows the form to be used without a provider. Since inject receives a function as its default value here without the third argument true, the function is used as it is, without being called.

Conclusion

Vue components communicate through several channels, each with its own purpose: props and events between parent and child, v-model for controls that edit a piece of the parent's data, slots for letting the parent decide part of the markup, refs with defineExpose for imperative actions and provide/inject for context data needed by descendants at any depth. Siblings coordinate by lifting state up to the common parent. provide/inject avoids prop drilling, and it is used well by providing reactive values as readonly together with functions for modifying them, with Symbol keys gathered in one file, default values when the component must work in isolation and app.provide for global configuration. The global event bus and state in a JavaScript module exist and have their uses, but their limits (invisible flow, leaks, lack of tooling, risks with SSR) are what motivate state management libraries. Colmena now has a member session that App provides and that AppHeader and BookingForm inject, a centre configuration provided from main.js and an App.vue that has become an orchestrator.

With this you complete the components module, and Colmena Bookings has changed completely on the inside: what was a single file hundreds of lines long is now a tree of components with clear responsibilities (AppHeader, RoomFilters, the three catalogue views with RoomCard and StatusBadge, BasePanel, BookingForm with TextField and BaseButton) that communicate through explicit channels. But on the outside it is still a single page: the catalogue, the details of the selected room and the booking form are all shown at once, one below the other; none of them has a URL of its own that can be bookmarked or shared, reloading the page returns everything to its initial state and the browser's Back button takes the user out of the application instead of back to the previous screen. A real application needs separate screens, each with its own address, and navigation between them that respects the browser's history. That is what Vue's official router provides, and we will start studying it in Introduction to Vue Router.

New edition · October 2026

Vue.js Course

Module 1: Introduction to Vue.js

Module 2: Vue.js Basics

Module 3: Vue.js Components

Module 4: Vue Router

Module 5: State Management with Vuex and Pinia

Module 6: Vue.js Directives

Module 7: Vue.js Plugins

Module 8: Testing in Vue.js

Module 9: Advanced Vue.js Concepts

Module 10: Building and Deploying Vue.js Applications

Module 11: Real-World Vue.js Projects

© Copyright 2026. All rights reserved