The future is standalone!

Angular v19 will make standalone: true the default for components, directives, and pipes.In v14 we introduced a developer preview “standalone” feature, which made it possible for the first time to build an application that didn’t rely on NgModules. Sin…


This content originally appeared on Angular Blog - Medium and was authored by Alex Rickabaugh

The future is standalone!

Angular v19 will make standalone: true the default for components, directives, and pipes.

In v14 we introduced a developer preview “standalone” feature, which made it possible for the first time to build an application that didn’t rely on NgModules. Since then, standalone has been stabilized, and has become the recommended way to write Angular code by the Angular team. The CLI generates components with standalone: true by default, and the Angular docs teach standalone first to all new Angular developers. Adoption is strong and continues to grow across the Angular ecosystem, both in the largest Angular applications written at Google as well as applications across the internet.

Not only does standalone make Angular easier to learn and get started with, it’s also enabled a few exciting new features. In @angular/router, loadComponent simplifies route-level lazy loading significantly and relies on standalone functionality. The Directive Composition API enables a better composition model for component behavior by allowing standalone directives to be applied in the declaration of a host component or directive. And of course, Deferrable Views transparently lazy-load standalone components and directives at the template level, making it easier than ever to optimize your Angular applications.

In v19 we’ll take the next step, and flip the default of the standalone flag in components, directives, and pipes, so you’ll never need to type “standalone: true” again. With this change, components like:

will be written as:

What if I’m still using NgModules?

That’s fine — we’re not deprecating the standalone option or NgModules themselves. You’ll still be able to write NgModule components by specifying standalone: false in the component decorator.

What will I need to do for my existing standalone or NgModules code?

As part of ng update for v19, we’ll apply an automated migration which will:

  • Remove standalone: true for existing standalone components, as it will be the new default.
  • Add standalone: false to existing NgModule components so they continue to work.

Optionally, you’ll be able to set the strictStandalone compiler option to enforce that only standalone components are written in your application.

What about FormsModule & other npm libraries with NgModules?

Nothing will change here. Standalone components can continue to import NgModule dependencies as needed, even with the strictStandalone compiler option enabled.

If you’re authoring a library published on NPM, you also don’t need to do anything — your components will behave correctly when imported by users regardless of whether they’re using v19 with the new default or not.


The future is standalone! was originally published in Angular Blog on Medium, where people are continuing the conversation by highlighting and responding to this story.


This content originally appeared on Angular Blog - Medium and was authored by Alex Rickabaugh


Print Share Comment Cite Upload Translate Updates
APA

Alex Rickabaugh | Sciencx (2024-09-03T16:18:46+00:00) The future is standalone!. Retrieved from https://www.scien.cx/2024/09/03/the-future-is-standalone/

MLA
" » The future is standalone!." Alex Rickabaugh | Sciencx - Tuesday September 3, 2024, https://www.scien.cx/2024/09/03/the-future-is-standalone/
HARVARD
Alex Rickabaugh | Sciencx Tuesday September 3, 2024 » The future is standalone!., viewed ,<https://www.scien.cx/2024/09/03/the-future-is-standalone/>
VANCOUVER
Alex Rickabaugh | Sciencx - » The future is standalone!. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2024/09/03/the-future-is-standalone/
CHICAGO
" » The future is standalone!." Alex Rickabaugh | Sciencx - Accessed . https://www.scien.cx/2024/09/03/the-future-is-standalone/
IEEE
" » The future is standalone!." Alex Rickabaugh | Sciencx [Online]. Available: https://www.scien.cx/2024/09/03/the-future-is-standalone/. [Accessed: ]
rf:citation
» The future is standalone! | Alex Rickabaugh | Sciencx | https://www.scien.cx/2024/09/03/the-future-is-standalone/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.