Description
Use standalone components instead of NgModules to create more modular, simpler, and easier-to-maintain Angular applications.
When to use:
- New applications - Standalone components are the recommended approach for new projects
- Component libraries - Standalone components are easier to package and distribute
- Micro-frontends - Better isolation and independence between different parts of the application
- Lazy loading - Simpler lazy loading without complex module structures
Benefits:
- Simplified Architecture - Eliminates the need for NgModules in most cases
- Better Tree-shaking - More efficient bundling with unused code elimination
- Easier Testing - Components can be tested in isolation without module setup
- Improved Developer Experience - Less boilerplate and clearer dependencies
- Better Code Organization - Dependencies are declared at the component level
When NOT to use:
- Legacy applications where migration costs outweigh benefits
- When working with libraries that haven’t adopted standalone components yet
- Complex applications that benefit from NgModule-based feature organization (though this is increasingly rare)