Back to results for “Components & Templates”
Angular › Standalone Components

What is a standalone component in Angular, and how do you create one?

Beginner

Answer

A standalone component declares its own dependencies, like which other components or directives it uses, directly within itself using an imports array, without needing to be registered inside a separate NgModule. New Angular projects use standalone components by default.
@Component({
  selector: 'app-greeting',
  standalone: true,
  imports: [CommonModule],
  template: `<p>Hello there</p>`
})
export class GreetingComponent {}
Real-world example A new Angular project built entirely with standalone components skips creating any NgModules at all, keeping each component's own dependencies clearly listed right where they are actually used.

Common follow-ups: Can standalone components be used together with existing NgModule based components in the same app?;Why did Angular introduce standalone components as the new default approach?