How to Build a To-Do App in Vue 3 Using the Composition API

A to-do app may be simple, but itโ€™s one of the best projects to understand how Vue 3โ€™s Composition API works. It teaches reactivity, component structure, state management, and event handlingโ€”all the essentials you need to grow into a confident Vue developer. Letโ€™s walk through building a clean and functional to-do app step-by-step.

๐Ÿญ. ๐—ฆ๐—ฒ๐˜๐˜๐—ถ๐—ป๐—ด ๐—จ๐—ฝ ๐˜๐—ต๐—ฒ ๐—ฉ๐˜‚๐—ฒ ๐Ÿฏ ๐—ฃ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜

Start by creating a new Vue project with Vite:

npm create vue@latest
cd your-project
npm install
npm run dev

Inside your src directory, youโ€™ll work primarily in App.vue or separate components if you prefer a modular approach.

๐Ÿฎ. ๐—จ๐˜€๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—–๐—ผ๐—บ๐—ฝ๐—ผ๐˜€๐—ถ๐˜๐—ถ๐—ผ๐—ป ๐—”๐—ฃ๐—œ ๐—ณ๐—ผ๐—ฟ ๐—ฆ๐˜๐—ฎ๐˜๐—ฒ

With the Composition API, we use ref() and reactive() to track reactive data. For a to-do list, we need:

  • An input field for new tasks
  • A list to store all tasks
  • Methods to add, toggle, and delete tasks
import { ref } from \'vue\';

const newTask = ref(\'\');
const tasks = ref([]);

๐Ÿฏ. ๐—•๐˜‚๐—ถ๐—น๐—ฑ๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—”๐—ฑ๐—ฑ ๐—ง๐—ฎ๐˜€๐—ธ ๐—™๐˜‚๐—ป๐—ฐ๐˜๐—ถ๐—ผ๐—ป

This function pushes a new task into the array and clears the input:

const addTask = () => {
  if (!newTask.value.trim()) return;

  tasks.value.push({
    id: Date.now(),
    text: newTask.value,
    completed: false
  });

  newTask.value = \'\';
};

๐Ÿฐ. ๐—ง๐—ผ๐—ด๐—ด๐—น๐—ถ๐—ป๐—ด & ๐——๐—ฒ๐—น๐—ฒ๐˜๐—ถ๐—ป๐—ด ๐—ง๐—ฎ๐˜€๐—ธ๐˜€

const toggleTask = (id) => {
  const task = tasks.value.find(t => t.id === id);
  task.completed = !task.completed;
};

const deleteTask = (id) => {
  tasks.value = tasks.value.filter(t => t.id !== id);
};

๐Ÿฑ. ๐—–๐—ฟ๐—ฒ๐—ฎ๐˜๐—ถ๐—ป๐—ด ๐˜๐—ต๐—ฒ ๐—ง๐—ฒ๐—บ๐—ฝ๐—น๐—ฎ๐˜๐—ฒ

Use Vueโ€™s directives to bind the UI:

<input v-model=\"newTask\" @keyup.enter=\"addTask\" placeholder=\"Add a task...\" />

<ul>
  <li v-for=\"task in tasks\" :key=\"task.id\">
    <input type=\"checkbox\" v-model=\"task.completed\" @change=\"toggleTask(task.id)\" />
    <span :class=\"{ \'line-through\': task.completed }\">{{ task.text }}</span>
    <button @click=\"deleteTask(task.id)\">Delete</button>
  </li>
</ul>

Tailwind or simple CSS can be used to style it.

๐Ÿฒ. ๐—™๐—ถ๐—ป๐—ฎ๐—น ๐—ง๐—ต๐—ผ๐˜‚๐—ด๐—ต๐˜๐˜€

This small project reveals the power of the Composition APIโ€”clean logic, reusable functions, and a predictable state flow. Once comfortable, you can extend the app with localStorage, animations, filters, or even move logic to composables.

Building a to-do app in Vue 3 is a perfect foundation for mastering more advanced web applications.

If you are looking for any services related to Website Development, App Development, Digital Marketing and SEO, just email us at nchouksey@manifestinfotech.com

#Vuejs #Vue3 #CompositionAPI #TodoApp #JavaScript #FrontendDevelopment #WebDevelopment #VueTutorial #CodingProjects #VueDevelopers #JSDeveloper #LearnVue #ModernFrontend #VueApps #DeveloperTips #VueEcosystem #BeginnerProjects #CleanCode #WebAppDevelopment #ProgrammingBasics