Skip to content
Learn Netverks

Lesson

Step 8/36 22% through track

component-basics

Component basics

Last reviewed Jun 1, 2026 Content v20260601
Track mode
client_vue
Means
In-browser Vue TS
Reading
~2 min
Level
beginner

This lesson

This lesson teaches Component basics: the concepts, APIs, and habits you need before advancing in Vue.

Without Component basics, you will struggle to read or extend Vue codebases and playground exercises.

You will apply Component basics in contexts like: Greenfield SPAs, dashboards, design systems, and full-stack apps that pair Vue with PHP or Node APIs.

Write TypeScript, click Run—Vue 3 loads from CDN with the template compiler, mountApp shows UI in #app, and printOutput feeds the terminal.

When you can explain the previous lesson's ideas without copying starter code.

A Vue component is a reusable unit with its own template and logic. In this playground, components are plain objects with setup() and a template string—similar to how React lessons use function components before introducing files.

Naming and structure

  • Component names use PascalCase in JavaScript: UserCard.
  • In templates, use PascalCase or kebab-case: <UserCard /> or <user-card />.
  • Keep components focused—one clear responsibility per file in real Vite projects.
  • Register locally by assigning to a property on the parent (playground pattern) or globally in apps.

setup() return value

Whatever setup() returns is exposed to the template—refs, functions, computed values. Think of it as the component’s public surface, like values used in a React function component’s JSX.

Important interview questions and answers

  1. Q: Options API vs Composition API?
    A: Options API groups by concern (data, methods); Composition API colocates logic in setup(). Vue 3 recommends Composition for new code; both compile to the same reactivity system.
  2. Q: Where does side-effect code go?
    A: In lifecycle hooks like onMounted or watchers—not as bare top-level async in setup() without consideration.

Self-check

  1. Why must component names start with a capital letter?
  2. What does setup() return?

Challenge

Card component

  1. Extract a Card component with title and body props.
  2. Render two Card instances from App.

Done when: two cards appear with different titles in the preview.

Interview tip Lesson completion confidence

Can you explain this lesson in 30 seconds without reading notes?

Not saved yet.

Playground

Runs in your browser in a sandboxed frame. Backend runners appear when this track’s profile allows them.

Check yourself

Multiple choice — immediate feedback.

Discussion

Past discussion is visible to everyone. Only logged-in users can post comments and replies.

Starter discussion topics

  • Component name convention?
  • Local vs global register?

Sign up or log in to post comments and sync lesson progress across devices.

No discussion yet. Be the first to ask a question.

Jump