Vue js Project Structure
Introduction
When generating a Vue application using tools like Vite or Vue CLI, a specific directory setup is initialized. This structure guides developers in organizing logic, interface components, assets, and configuration in a scalable, modular way.
Top-Level Layout
After creating a Vue workspace, the root contains these main elements:
- node_modules/ – Houses all installed external libraries.
- package.json – Lists dependencies, scripts, metadata.
- vite.config.js or vue.config.js – Contains project-specific tooling settings.
- .gitignore – Specifies files Git should exclude.
- README.md – Serves as documentation for the repo.
- public/ – Holds static files served directly (e.g., favicon, robots.txt).
Core Source Directory (src/)
This is the application’s heart where all logical layers live:
main.js or main.ts
Acts as the primary entry script that initializes the Vue instance and mounts the application.
import { createApp } from 'vue';
import App from './App.vue';
CreateApp(App).mount('#app');App.vue
This is the root view—it's where other subcomponents are injected. It can also include the global layout, such as headers or footers.
Component Folder (components/)
Reusable pieces of UI go here. For instance:
- HeaderBar.vue
- SidebarMenu.vue
- FormInput.vue
Each file encapsulates its own structure
(<template>),
style
(<style>),
and behavior
(<script>).
State Management (store/)
If Vuex or Pinia is used, this folder stores centralized data models or modules:
- index.js (Vuex entry file)
- Separate modules for users, settings, products, etc.
Routing Configuration (router/)
Contains files defining the application's navigation routes.
- index.js or routes.js
- Path-to-component mappings
- Meta info for protected paths or page titles
Views (views/)
This directory separates route-based pages from reusable pieces. Each .vue file here typically maps to a unique route (e.g., Home, About, Contact).
Assets (assets/)
Static files like images, icons, fonts, or raw CSS can be placed here.
assets/
├── logo.png
├── styles.css
└── font.woff2Utilities or Helpers (utils/ or helpers/)
This folder might store JavaScript functions, filters, formatters, or services.
Example: dateFormatter.js, apiService.js
Testing Files (tests/)
If test frameworks are integrated, this folder includes unit or integration test scripts for components and logic.
Custom Composition (composables/)
In Vue 3 setups using Composition API, this folder holds shared logic:
- useAuth.js
- useTheme.js
- useToggle.js
Styles (styles/ or scss/)
Can include global CSS, SCSS, or utility classes used across multiple parts.
Environment Variables (.env)
Environment-specific configuration like API endpoints or mode toggles (e.g., development, staging, production).
Summary
Each segment in the Vue folder blueprint plays a distinct role—whether managing shared code, providing UI blocks, or handling navigation logic—offering clarity, separation of responsibility, and smoother collaboration across teams.
Prefer Learning by Watching?
Watch these YouTube tutorials to understand VUE JS Tutorial visually:
What You'll Learn:
- 📌 Vue JS 3 Tutorial - 3 - Project Structure
- 📌 04 - Get to Know Vuejs Project File and Folder Structure