Getting started
This guide will walk you through setting up the Angular 18 Archetype and running your first development server.
Before starting, make sure you have Node.js 18.x or later and Angular CLI installed. See the introduction for prerequisites.
Clone the repository
Clone the project
Clone the repository to your local machine: git clone < repository-ur l > angular-18-archetype
cd angular-18-archetype
Replace <repository-url> with the actual URL of your repository.
Verify the structure
Check that you have the correct project structure: You should see:
src/ - Source code directory
package.json - Project dependencies
angular.json - Angular configuration
tsconfig.json - TypeScript configuration
Install dependencies
Install npm packages
Install all project dependencies: This will install Angular 18.2, ngx-translate, and all development dependencies.
Verify installation
Confirm the installation was successful: You should see all dependencies from package.json listed.
If you encounter peer dependency warnings, you can safely ignore them or use npm install --legacy-peer-deps if needed.
Run the development server
Start the dev server
Launch the development server: Or using Angular CLI directly: The application will start on http://localhost:4200/
Open in browser
Navigate to http://localhost:4200/ in your browser. The app will automatically reload whenever you make changes to the source files.
The development server uses Angular’s default configuration with source maps enabled for easier debugging.
Make your first changes
Let’s make a simple change to verify everything is working:
Open the main component
Open src/app/app.component.ts in your editor: import { Component , inject } from '@angular/core' ;
import { RouterOutlet } from '@angular/router' ;
import { TranslateModule } from '@ngx-translate/core' ;
import { LanguageSwitchService } from './core/language-switch/language-switch.service' ;
import { NavbarComponent } from './core/language-switch/language-switch.component' ;
@ Component ({
selector: 'app-root' ,
standalone: true ,
imports: [ RouterOutlet , TranslateModule , NavbarComponent ],
templateUrl: './app.component.html' ,
styleUrl: './app.component.scss'
})
export class AppComponent {
title = 'angular-18-archetype' ;
languageService = inject ( LanguageSwitchService );
constructor () {
this . languageService . setLanguage ( 'es' )
}
}
Change the default language
Modify the default language from Spanish to English: constructor () {
this . languageService . setLanguage ( 'en' ) // Changed from 'es' to 'en'
}
Save the file and observe the automatic reload in your browser.
Test the language switcher
The archetype includes a language switcher component. Try switching between English and Spanish using the UI component. The language preference is automatically saved to localStorage and persists across sessions.
Understanding the project structure
The archetype uses a structured folder organization:
src/
├── app/
│ ├── config/ # App configuration and factories
│ ├── core/ # Core services, guards, interceptors
│ │ ├── language-switch/
│ │ ├── layout/
│ │ └── providers/
│ ├── shared/ # Shared code across features
│ │ ├── domain/ # Type definitions
│ │ ├── services/ # Shared services
│ │ │ ├── state/ # State management
│ │ │ └── utils/ # Utility services
│ │ └── ui/ # Reusable UI components
│ ├── app.component.ts
│ ├── app.config.ts # Application providers
│ └── app.routes.ts # Route definitions
├── assets/
│ └── i18n/ # Translation files (en.json, es.json)
└── environments/ # Environment configurations
TypeScript path aliases
The archetype includes pre-configured path aliases for cleaner imports:
import { NotificationComponent } from '@ui/notifications.component' ;
import { User } from '@domain/user.type' ;
import { AuthStore } from '@state/auth.store' ;
import { LocalRepository } from '@services/utils/local.repository' ;
Available scripts
The archetype includes these npm scripts:
Development server
Build for production
Watch mode
Run tests
Angular CLI
npm start
# Starts the dev server at http://localhost:4200/
Build for production
Create production build
Build the application for production: This creates an optimized build in the dist/angular-18-archetype/ directory.
Review build output
The production build includes:
Output hashing for cache busting
Bundle optimization and minification
Tree shaking for smaller bundle sizes
Source maps disabled by default
The build has budget limits configured: 500kB warning, 1MB error for initial bundles.
Test production build locally
You can test the production build locally using a static file server: npx serve dist/angular-18-archetype/browser
Generate new components
Use Angular CLI to generate new components, services, and other artifacts:
Component
Service
Guard
Interceptor
Generate a new component: ng generate component feature/my-component
Or using the shorthand: ng g c feature/my-component
Generate a new service: ng generate service shared/services/my-service
Or using the shorthand: ng g s shared/services/my-service
Generate a new guard: ng generate guard core/providers/my-guard
Generate a new interceptor: ng generate interceptor core/providers/my-interceptor
All generated components will be standalone by default, matching the archetype’s approach.
Working with translations
The archetype uses ngx-translate for internationalization:
Add translation keys
Edit the translation files in src/assets/i18n/: {
"WELCOME" : "Welcome to Angular 18 Archetype" ,
"DESCRIPTION" : "A production-ready starter template"
}
{
"WELCOME" : "Bienvenido a Angular 18 Archetype" ,
"DESCRIPTION" : "Una plantilla inicial lista para producción"
}
Use translations in components
Import TranslateModule and use the translate pipe: import { TranslateModule } from '@ngx-translate/core' ;
@ Component ({
// ...
imports: [ TranslateModule ],
template: `
<h1>{{ 'WELCOME' | translate }}</h1>
<p>{{ 'DESCRIPTION' | translate }}</p>
`
})
Switch languages programmatically
Use the LanguageSwitchService: import { LanguageSwitchService } from './core/language-switch/language-switch.service' ;
export class MyComponent {
languageService = inject ( LanguageSwitchService );
switchToEnglish () {
this . languageService . setLanguage ( 'en' );
}
}
Available languages are defined in LanguageSwitchService.availableLanguages: [‘en’, ‘es’]
Next steps
Now that you have the archetype running, explore these topics:
Architecture guide Learn about the folder structure and architectural decisions
State management Understand the state management patterns using stores
Authentication Implement authentication using the included guard and interceptor
Deployment Deploy your application to production
Remember to update the README.md with project-specific information and replace placeholder content with your actual project details.
Getting help
If you encounter issues or have questions: