Chapter 20: Vue First SFC Page

Step 1 – What is a “First SFC Page” in Vue 3?

In beginner tutorials you often see only App.vue — that’s the root component.

But in real applications (even medium-sized ones), the structure looks like this:

text

HomeView.vue (or sometimes just Home.vue) is what most people mean by “first SFC page”.

It is:

  • A full-screen component
  • Mapped to the / route (home page)
  • Usually contains the main landing content / hero section / welcome message

Step 2 – Create a Fresh Vite + Vue + TypeScript Project

If you haven’t already, run this in your terminal (takes ~20 seconds):

Bash

You now have a running app at http://localhost:5173

Step 3 – Your Very First SFC Page → HomeView.vue

  1. Create the folder & file

    text
  2. Paste this clean, modern, 2026-style code:

vue

Step 4 – Connect It to Routing (Very Important!)

  1. Install vue-router if not already there

    Bash
  2. Create src/router/index.ts

TypeScript
  1. Update src/main.ts
TypeScript
  1. Make sure App.vue has <router-view>
vue

Now run npm run dev → visit http://localhost:5173 You should see your beautiful HomeView page!

Summary – What You Just Built

You created your first real SFC page:

  • Lives in views/ folder
  • Uses modern <script setup lang=”ts”>
  • Has reactive state (ref, computed)
  • Uses router navigation (useRouter, <router-link>)
  • Has scoped styles
  • Feels like a proper landing page

This pattern is used in 99% of medium+ Vue 3 projects in 2026.

Next natural steps after this:

  1. Create AboutView.vue and add /about route
  2. Add a simple Pinia store for global user state
  3. Build a todo list or dashboard inside a new view

Any part you want me to explain more slowly?

  • Why lazy-load components with () => import()?
  • How to create AboutView right now?
  • Add dark mode toggle on this home page?
  • Folder structure debate (views vs pages)?

Just tell me — we’ll build the next piece together 🚀

Happy first-page coding from Hyderabad! 💙

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *