Vue.js course · Module 1: Vue and Vite

What is Vue.js?

6 min read ·
In this lesson5

Welcome to the NOVA LAB Launch Zone! I'm Dr. Nova and I'll be your mentor. This is where we initialize all systems that will fly to Mars. Vue.js is the framework that powers our mission interfaces - from control panels to life support systems.

Picture a life support panel built without any framework. The oxygen level changes every few seconds, and every new reading has to be written by hand into the right place on the page:

// Without a framework: every reading means a manual screen update
const oxygenDisplay = document.querySelector('#oxygen')
oxygenDisplay.textContent = '98.5%'

This code works, but only once. With the next reading you have to find the element again and replace its text again - and do that for every indicator, because the number in the code and the label on the screen are not connected in any way. Vue turns this around: you describe what the screen should show for the mission data, and the framework makes sure the picture always matches it.

What you will learn

  • what Vue.js is and why we call it a progressive framework,
  • what the simplest component with ref() and {{ }} mustaches looks like,
  • what the three NOVA LAB protocols are built on,
  • what Vue 3 brought and which tools make up the mission ecosystem.

Vue.js - The Space Mission Framework

Vue.js (pronounced /vjuː/, like the English word "view") is a progressive JavaScript framework for building user interfaces. It was created by Evan You, and its first version came out in 2014. In 2087 it's still in use because it has proven itself in the most extreme conditions - in space.

Why "progressive"?

Vue can be adopted incrementally - from a simple interface to an advanced ship control system. It's like building a rocket:

  • First a prototype (basic Vue)
  • Then a full rocket (components, routing)
  • Finally an interplanetary vessel (full application)

You can add Vue to an existing page with a single script, or build a whole application with it using the Vite tool. At NOVA LAB we work with the full setup of Vite and .vue files from day one - that's how real projects are built, and that's the start I recommend.

NOVA LAB Protocols

Our coding principles are built on three pillars:

1. Simplicity (KISS Protocol)

The simplest component has two parts. The template in the <template> tag describes what appears on the screen, and the <script setup> section holds the data. We bring in the ref function with an import statement from the vue package and pass it a starting value:

<template>
  <h1>{{ missionName }}</h1>
</template>

<script setup>
import { ref } from 'vue'
const missionName = ref('MARS ONE')
</script>

The ref() function creates a reactive container: Vue watches its contents and knows when they change. The double curly braces, called mustaches, insert the container's current value into the template. The <h1> tag is still plain HTML - Vue only added a slot for the data. When the mission name changes, the heading updates by itself, with no code hunting for the element on the page.

You can have as many containers as you like, and mustaches can be woven into ordinary text, so any label can stand before or after them:

<template>
  <h2>{{ stationName }}</h2>
  <p>Crew: {{ crewCount }} people</p>
  <p>Oxygen reserve: {{ oxygenReserve }}%</p>
</template>

<script setup>
import { ref } from 'vue'

const stationName = ref('Nova Base')
const crewCount = ref(4)
const oxygenReserve = ref(92)
</script>

Each value got its own ref(), and a single import served all three. The labels "Crew:" and "%" stayed plain text - Vue replaces only what sits inside the mustaches. We'll take both tools apart in the lesson on your first Vue system.

2. Reliability (ZERO-FAULT Protocol)

Vue code is predictable - critical for life support systems. The template declares how the screen should look for a given state, and you change only the data, never the page directly.

3. Performance (LIGHT Protocol)

Vue uses Virtual DOM - every kilobyte less means more fuel on board. After a data change, Vue builds a lightweight description of the screen in memory, compares it with the previous one and applies only the differences to the page, while the compiler marks the parts that never change so they can be skipped.

Vue 3 - The Space Generation

Vue 3 came out in 2020 and it's the version we use at NOVA LAB - Vue 2 reached the end of its support at the end of 2023. Vue 3 introduced changes crucial for space missions:

  • Composition API - modular system organization
  • Better performance - smaller bundle, faster responses
  • TypeScript - typing eliminates bugs before launch
  • Teleport, Suspense - advanced UI techniques

The Composition API is the style you just saw: you write data and functions in <script setup>. The older Options API still works, but we don't use it. Teleport moves a piece of the template to another place on the page, and Suspense shows a waiting screen for data - the Vue documentation still marks it as experimental.

NOVA LAB Ecosystem

ToolMission Application
ViteCompilation engine - lightning fast
Vue RouterNavigation between base sections
PiniaMission central computer
VitestPre-launch tests
VueUseReusable protocols
NuxtMars base server

Vue Router and Pinia are official libraries of the Vue team. Pinia manages state shared by the whole application - in the Vue world you don't reach for Redux or the Context API known from React. Vite was written by the same author as Vue, and in the next lesson you'll start this engine.

In the editor below, a panel with an energy counter is waiting for you. Click plus and minus, watch the status change, and find the mustaches and ref() in the code.

Remember: Vue is a progressive framework in which you describe what the screen should show, and the system itself makes sure the picture always matches the mission data.

Code for this lesson: src/App.vue
<template>
  <div class="nova-lab">
    <header class="lab-header">
      <h1>NOVA LAB - Launch Zone</h1>
      <p class="subtitle">Year 2087 - Mars Mission Research Center</p>
    </header>

    <main class="lab-content">
      <section class="welcome-panel">
        <h2>Welcome, Engineer!</h2>
        <p>
          This is your first Vue.js component in NOVA LAB.
          We created it using Vite - a lightning-fast build tool.
        </p>
        <p>
          <strong>Dr. Nova:</strong> "Every great system starts with a small component.
          Your journey to Mars has just begun!"
        </p>
      </section>

      <section class="info-panel">
        <h3>What is Vue.js?</h3>
        <ul>
          <li>Progressive JavaScript framework</li>
          <li>Reactive data system</li>
          <li>Reusable components</li>
          <li>Great developer tools</li>
        </ul>
      </section>

      <section class="counter-demo">
        <h3>Interactive Energy Counter</h3>
        <div class="counter">
          <button @click="powerLevel--" class="btn">-</button>
          <span class="power-display">{{ powerLevel }}%</span>
          <button @click="powerLevel++" class="btn">+</button>
        </div>
        <p class="status" :class="powerStatus">
          Status: {{ powerStatusText }}
        </p>
      </section>
    </main>

    <footer class="lab-footer">
      <p>NOVA LAB © 2087 - Preparing for Mars Colonization</p>
    </footer>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue'

const powerLevel = ref(50)

const powerStatus = computed(() => {
  if (powerLevel.value < 20) return 'critical'
  if (powerLevel.value < 50) return 'warning'
  return 'nominal'
})

const powerStatusText = computed(() => {
  if (powerLevel.value < 20) return 'CRITICAL'
  if (powerLevel.value < 50) return 'WARNING'
  return 'NOMINAL'
})
</script>

<style>
.nova-lab {
  min-height: 100vh;
  background: linear-gradient(135deg, #0a0e27 0%, #1a1e37 100%);
  color: #e0e0e0;
  font-family: 'Segoe UI', system-ui, sans-serif;
  padding: 2rem;
}

.lab-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid #00ff88;
}

.lab-header h1 {
  color: #00ff88;
  font-size: 2.5rem;
  margin: 0;
  text-shadow: 0 0 20px rgba(0, 255, 136, 0.5);
}

.subtitle {
  color: #00b4d8;
  margin-top: 0.5rem;
}

.lab-content {
  max-width: 800px;
  margin: 0 auto;
}

section {
  background: rgba(26, 30, 55, 0.8);
  border: 1px solid #00b4d8;
  border-radius: 12px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
}

h2, h3 {
  color: #00ff88;
  margin-top: 0;
}

ul {
  list-style: none;
  padding: 0;
}

ul li {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(0, 180, 216, 0.3);
}

ul li::before {
  content: "→ ";
  color: #00ff88;
}

.counter {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  margin: 1rem 0;
}

.btn {
  background: #00b4d8;
  color: #0a0e27;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 1.5rem;
  cursor: pointer;
  transition: all 0.3s;
}

.btn:hover {
  background: #00ff88;
  transform: scale(1.1);
}

.power-display {
  font-size: 2rem;
  font-weight: bold;
  color: #00ff88;
  min-width: 100px;
  text-align: center;
}

.status {
  text-align: center;
  padding: 0.5rem;
  border-radius: 8px;
  font-weight: bold;
}

.status.nominal { background: rgba(0, 255, 136, 0.2); color: #00ff88; }
.status.warning { background: rgba(255, 170, 0, 0.2); color: #ffaa00; }
.status.critical { background: rgba(255, 68, 68, 0.2); color: #ff4444; }

.lab-footer {
  text-align: center;
  margin-top: 2rem;
  color: #666;
  font-size: 0.9rem;
}
</style>

Docs entries used in this lesson

Spotted a mistake in this lesson?

Check yourself

Answer the questions from this lesson. Pick an answer to see right away whether it is correct.

  1. 1. What does it mean that Vue.js is a progressive framework?

  2. 2. Which of the following is a new feature of Vue 3?

  3. 3. Which library is the Vue team's official tool for managing application state?

Hands-on tasks in the game

  • Code editor

    Complete the Vue component so that it displays a greeting from NOVA LAB. Use ref() and {{ }} interpolation.

  • Click in order

    Arrange the data interpolation syntax in a Vue template:

  • Code editor

    Create a component with several ref() variables and display them in the template using {{ }}.

  1. QuestionVue.js as a progressive framework
  2. QuestionNew features of Vue 3
  3. Coding taskPractice: First Vue component
  4. QuestionState management in Vue
  5. Click in orderVue interpolation syntax
  6. Coding taskPractice: Data interpolation

Useful articles