Component-First Architecture with Angular and Standalone Components
Angular recently had an RFC (Request for Comments) on Standalone Components. It is an effort to make NgModules
in Angular optional. We do not want to remove them completely as many Angular apps currently rely on the building blocks that are NgModules
.
Manfred Steyer explored what this will mean for the ecosystem moving forward and how we can begin to think about writing our Angular apps in his short blog series: https://www.angulararchitects.io/en/aktuelles/angulars-future-without-ngmodules-part-2-what-does-that-mean-for-our-architecture/
Declarative Routing
I believe, however, that the best potential architecture we can achieve when Standalone Components are introduced, will be based around Declarative Routing.
Declarative Routing is a concept that we have seen implemented by packages such as react-router
. It involves declaring our routes as elements in our component’s template.
With Angular, we do not have an officially supported Declarative Routing solution, however, Brandon Roberts has created a package that implements this concept, called the Angular Component Router.
It allows us to define the Routes through our application in our components, removing the need to configure the…