Overview
The project follows Nuxt 3’s standard directory structure, which provides automatic imports, file-based routing, and a clear separation of concerns.Key Directories
components/
components/
Contains reusable Vue components that are automatically imported throughout the application.Auto-import: Components in this directory don’t need explicit imports in your pages or other components.Example:
components/Modal.vuecan be used as<Modal />anywhere without importing
composables/
composables/
Contains composable functions following the Vue Composition API pattern. These provide reusable logic for components.Auto-import: All composables are automatically available throughout your application.Key composables:
useApi()- Axios instance with authenticationuseServiceOrders()- Service orders state and operations
pages/
pages/
Implements file-based routing. Each Vue file becomes a route automatically.Structure:
stores/
stores/
Contains Pinia stores for global state management.Available stores:
auth.ts- Authentication state (user, token)
@pinia/nuxt module.layouts/
layouts/
Defines layout templates that wrap page content.Available layouts:
default.vue- Main layout with header and user menuempty.vue- Minimal layout for login page
definePageMeta().middleware/
middleware/
Contains route middleware for navigation guards.Available middleware:
auth.ts- Protects routes requiring authentication
definePageMeta({ middleware: 'auth' }).types/
types/
TypeScript type definitions and interfaces.Key types:
ServiceOrder.ts- Defines the service order data structure
utils/
utils/
Utility functions that are auto-imported across the application.Available utilities:
authService.ts- Authentication helper functions
Root Application Component
Theapp.vue file is the root component that wraps your entire application:
app.vue
<NuxtLayout>- Renders the active layout component<NuxtPage>- Renders the current page based on route
Configuration
Thenuxt.config.ts file configures your Nuxt application:
nuxt.config.ts
- modules: Nuxt modules including Pinia for state management
- runtimeConfig: Environment-specific configuration (API base URL)
- components: Auto-import components from the components directory
Auto-Imports
Nuxt 3 automatically imports components, composables, and utilities. You don’t need explicit import statements for:
- Components in
components/ - Composables in
composables/ - Utilities in
utils/ - Nuxt helpers like
navigateTo(),useRouter(),useState(), etc.
Example: Using Auto-Imports
Best Practices
- Follow naming conventions: Use PascalCase for components, camelCase for composables
- Leverage auto-imports: Don’t manually import what Nuxt provides automatically
- Organize by feature: Keep related files in subdirectories (e.g.,
pages/serviceorders/) - Use TypeScript: Define types in the
types/directory for better type safety - Modular composables: Keep composables focused on a single responsibility
Next Steps
State Management
Learn how to use Pinia stores for global state
Composables
Discover reusable composable functions
API Integration
Understand how to make API calls