Skip to content

The @nx/angular plugin provides various generators to help you create and configure angular projects within your Nx workspace. Below is a complete reference for all available generators and their options.

application

Creates an Angular application.

Examples

{% tabs %} {% tab label=“Simple Application” %}

Create an application named my-app:

Terminal window
nx g @nx/angular:application apps/my-app

{% /tab %}

{% tab label=“Specify style extension” %}

Create an application named my-app in the my-dir directory and use scss for styles:

Terminal window
nx g @nx/angular:app my-dir/my-app --style=scss

{% /tab %}

{% tab label=“Single File Components application” %}

Create an application with Single File Components (inline styles and inline templates):

Terminal window
nx g @nx/angular:app apps/my-app --inlineStyle --inlineTemplate

{% /tab %}

{% tab label=“Set custom prefix and tags” %}

Set the prefix to apply to generated selectors and add tags to the application (used for linting).

Terminal window
nx g @nx/angular:app apps/my-app --prefix=admin --tags=scope:admin,type:ui

{% /tab %} {% /tabs %}

Usage:

Terminal window
nx generate @nx/angular:application [options]

Aliases: app

Arguments:

Terminal window
nx generate @nx/angular:application <directory> [options]

Options

OptionTypeDescriptionDefault
addTailwindbooleanWhether to configure Tailwind CSS for the application.false
backendProjectstringBackend project that provides data to this application. This sets up proxy.config.json.
bundlerstringBundler to use to build the application."esbuild"
e2eTestRunnerstringTest runner to use for end to end (E2E) tests."playwright"
inlineStylebooleanSpecifies if the style will be in the ts file.false
inlineTemplatebooleanSpecifies if the template will be in the ts file.false
linterstringThe tool to use for running lint checks."eslint"
minimalbooleanGenerate a Angular app with a minimal setup.false
namestringThe name of the application.
portnumberThe port at which the remote application should be served.
prefixstringThe prefix to apply to generated selectors."app"
rootProjectbooleanCreate an application at the root of the workspace.false
routingbooleanEnable routing for the application.true
serverRoutingbooleanCreates a server application using the Server Routing and App Engine APIs for application using the application builder (Developer Preview). Note: this is only supported in Angular versions 19.x.x. From Angular 20 onwards, SSR will always enable server routing when using the application builder.
setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
skipFormatbooleanSkip formatting files.false
skipPackageJsonbooleanDo not add dependencies to package.json.false
skipTestsbooleanSkip creating spec files.false
ssrbooleanCreates an application with Server-Side Rendering (SSR) and Static Site Generation (SSG/Prerendering) enabled.false
standalonebooleanGenerate an application that is setup to use standalone components.true
strictbooleanCreate an application with stricter type checking and build optimization options.true
stylestringThe file extension to be used for style files."css"
tagsstringAdd tags to the application (used for linting).
unitTestRunnerstringTest runner to use for unit tests."jest"
viewEncapsulationstringSpecifies the view encapsulation strategy.

component

Creates a new Angular component.

Examples

{% tabs %} {% tab label=“Simple Component” %}

Generate a component named Card at apps/my-app/src/lib/card/card.ts:

Terminal window
nx g @nx/angular:component apps/my-app/src/lib/card/card.ts

{% /tab %}

{% tab label=“Without Providing the File Extension” %}

Generate a component named Card at apps/my-app/src/lib/card/card.ts:

Terminal window
nx g @nx/angular:component apps/my-app/src/lib/card/card

{% /tab %}

{% tab label=“With Different Symbol Name” %}

Generate a component named Custom at apps/my-app/src/lib/card/card.ts:

Terminal window
nx g @nx/angular:component apps/my-app/src/lib/card/card --name=custom

{% /tab %}

{% tab label=“With a Component Type” %}

Generate a component named CardComponent at apps/my-app/src/lib/card/card.component.ts:

Terminal window
nx g @nx/angular:component apps/my-app/src/lib/card/card --type=component

{% /tab %}

{% tab label=“Single File Component” %}

Create a component named Card with inline styles and inline template:

Terminal window
nx g @nx/angular:component apps/my-app/src/lib/card/card --inlineStyle --inlineTemplate

{% /tab %}

{% tab label=“Component with OnPush Change Detection Strategy” %}

Create a component named Card with OnPush Change Detection Strategy:

Terminal window
nx g @nx/angular:component apps/my-app/src/lib/card/card --changeDetection=OnPush

{% /tab %}

Usage:

Terminal window
nx generate @nx/angular:component [options]

Aliases: c

Arguments:

Terminal window
nx generate @nx/angular:component <path> [options]

Options

OptionTypeDescriptionDefault
changeDetectionstringThe change detection strategy to use in the new component."Default"
displayBlockbooleanSpecifies if the style will contain :host { display: block; }.false
exportbooleanSpecifies if the component should be exported in the declaring NgModule. Additionally, if the project is a library, the component will be exported from the project’s entry point (normally index.ts) if the module it belongs to is also exported or if the component is standalone.false
exportDefaultbooleanUse default export for the component instead of a named export.false
inlineStylebooleanInclude styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file.false
inlineTemplatebooleanInclude template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.false
modulestringThe filename or path to the NgModule that will declare this component.
namestringThe component symbol name. Defaults to the last segment of the file path.
ngHtmlbooleanGenerate component template files with an ‘.ng.html’ file extension instead of ‘.html’.false
prefixstringThe prefix to apply to the generated component selector.
selectorstringThe HTML selector to use for this component.
skipFormatbooleanSkip formatting files.false
skipImportbooleanDo not import this component into the owning NgModule.false
skipSelectorbooleanSpecifies if the component should have a selector or not.false
skipTestsbooleanDo not create spec.ts test files for the new component.false
standalonebooleanWhether the generated component is standalone.true
stylestringThe file extension or preprocessor to use for style files, or none to skip generating the style file."css"
typestringAppend a custom type to the component’s filename. It defaults to ‘component’ for Angular versions below v20. For Angular v20 and above, no type is appended unless specified.
viewEncapsulationstringThe view encapsulation strategy to use in the new component.

component-test

Create a *.cy.ts file for Cypress component testing for an Angular component.

Examples

{% callout type=“caution” title=“Can I use component testing?” %} Angular component testing with Nx requires Cypress version 10.7.0 and up.

You can migrate with to v11 via the migrate-to-cypress-11 generator. {% /callout %}

This generator is used to create a Cypress component test file for a given Angular component.

Terminal window
nx g @nx/angular:component-test --project=my-cool-angular-project --componentName=CoolBtnComponent --componentDir=src/cool-btn --componentFileName=cool-btn.component

Test file are generated with the .cy.ts suffix. this is to prevent colliding with any existing .spec. files contained in the project.

It’s currently expected the generated .cy.ts file will live side by side with the component. It is also assumed the project is already setup for component testing. If it isn’t, then you can run the cypress-component-project generator to set up the project for component testing.

Usage:

Terminal window
nx generate @nx/angular:component-test [options]

Options

OptionTypeDescriptionDefault
componentDirstring [required]Relative path to the folder that contains the component from the project root.
componentFileNamestring [required]File name that contains the component without the .ts extension.
componentNamestring [required]Class name of the component to create a test for.
projectstring [required]The name of the project where the component is located.
skipFormatbooleanSkip formatting files.false

convert-to-application-executor

Converts a project or all projects using one of the @angular-devkit/build-angular:browser, @angular-devkit/build-angular:browser-esbuild, @nx/angular:browser and @nx/angular:browser-esbuild executors to use the @nx/angular:application executor or the @angular-devkit/build-angular:application builder. If the converted target is using one of the @nx/angular executors, the @nx/angular:application executor will be used. Otherwise, the @angular-devkit/build-angular:application builder will be used.

Usage:

Terminal window
nx generate @nx/angular:convert-to-application-executor [options]

Arguments:

Terminal window
nx generate @nx/angular:convert-to-application-executor <project> [options]

Options

OptionTypeDescriptionDefault
skipFormatbooleanSkip formatting files.false

convert-to-rspack

Creates an Angular application.

Usage:

Terminal window
nx generate @nx/angular:convert-to-rspack [options]

Arguments:

Terminal window
nx generate @nx/angular:convert-to-rspack <project> [options]

Options

OptionTypeDescriptionDefault
skipFormatbooleanSkip formatting files.false
skipInstallbooleanSkip installing dependencies.false

convert-to-with-mf

Converts an old micro frontend configuration to use the new withModuleFederation helper. It will run successfully if the following conditions are met:

  • Is either a host or remote application
  • Shared npm package configurations have not been modified
  • Name used to identify the Micro Frontend application matches the project name

{% callout type=“warning” title=“Overrides” %}This generator will overwrite your webpack config. If you have additional custom configuration in your config file, it will be lost!{% /callout %}.

Usage:

Terminal window
nx generate @nx/angular:convert-to-with-mf [options]

Arguments:

Terminal window
nx generate @nx/angular:convert-to-with-mf <project> [options]

Options

OptionTypeDescriptionDefault
skipFormatbooleanSkip formatting files.false

cypress-component-configuration

Add a Cypress component testing configuration to an existing project. Cypress v10.7.0 or higher is required.

{% callout type=“caution” title=“Can I use component testing?” %} Angular component testing with Nx requires Cypress version 10.7.0 and up.

You can migrate with to v11 via the migrate-to-cypress-11 generator.

This generator is for Cypress based component testing.

If you want to test components via Storybook with Cypress, then check out the storybook-configuration generator docs. However, this functionality is deprecated, and will be removed on Nx version 18. {% /callout %}

This generator is designed to get your Angular project up and running with Cypress Component Testing.

Terminal window
nx g @nx/angular:cypress-component-configuration --project=my-cool-angular-project

Running this generator, adds the required files to the specified project with a preconfigured cypress.config.ts designed for Nx workspaces.

import { defineConfig } from 'cypress';
import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';
export default defineConfig({
component: nxComponentTestingPreset(__filename),
});

Here is an example on how to add custom options to the configuration

import { defineConfig } from 'cypress';
import { nxComponentTestingPreset } from '@nx/angular/plugins/component-testing';
export default defineConfig({
component: {
...nxComponentTestingPreset(__filename),
// extra options here
},
});

Specifying a Build Target

Component testing requires a build target to correctly run the component test dev server. This option can be manually specified with --build-target=some-angular-app:build, but Nx will infer this usage from the project graph if one isn’t provided.

For Angular projects, the build target needs to be using the @nx/angular:webpack-browser or @angular-devkit/build-angular:browser executor. The generator will throw an error if a build target can’t be found and suggest passing one in manually.

Letting Nx infer the build target by default

Terminal window
nx g @nx/angular:cypress-component-configuration --project=my-cool-angular-project

Manually specifying the build target

Terminal window
nx g @nx/angular:cypress-component-configuration --project=my-cool-angular-project --build-target:some-angular-app:build --generate-tests

{% callout type=“note” title=“Build Target with Configuration” %} If you’re wanting to use a build target with a specific configuration. i.e. my-app:build:production, then manually providing --build-target=my-app:build:production is the best way to do that. {% /callout %}

Auto Generating Tests

You can optionally use the --generate-tests flag to generate a test file for each component in your project.

Terminal window
nx g @nx/angular:cypress-component-configuration --project=my-cool-angular-project --generate-tests

Running Component Tests

A new component-test target will be added to the specified project to run your component tests.

Terminal window
nx g component-test my-cool-angular-project

Here is an example of the project configuration that is generated. The --build-target option is added as the devServerTarget which can be changed as needed.

{
"targets" {
"component-test": {
"executor": "@nx/cypress:cypress",
"options": {
"cypressConfig": "<path-to-project-root>/cypress.config.ts",
"testingType": "component",
"devServerTarget": "some-angular-app:build",
"skipServe": true
}
}
}
}

What is bundled

When the project being tested is a dependent of the specified --build-target, then assets, scripts, and styles are applied to the component being tested. You can determine if the project is dependent by using the project graph. If there is no link between the two projects, then the assets, scripts, and styles won’t be included in the build; therefore, they will not be applied to the component. To have a link between projects, you can import from the project being tested into the specified --build-target project, or set the --build-target project to implicitly depend on the project being tested.

Nx also supports React component testing.

Usage:

Terminal window
nx generate @nx/angular:cypress-component-configuration [options]

Options

OptionTypeDescriptionDefault
projectstring [required]The name of the project to add cypress component testing configuration to
buildTargetstringA build target used to configure Cypress component testing in the format of project:target[:configuration]. The build target should be an angular app. If not provided we will try to infer it from your projects usage.
generateTestsbooleanGenerate default component tests for existing components in the projectfalse
skipFormatbooleanSkip formatting filesfalse

directive

Creates a new Angular directive.

Usage:

Terminal window
nx generate @nx/angular:directive [options]

Aliases: d

Arguments:

Terminal window
nx generate @nx/angular:directive <path> [options]

Options

OptionTypeDescriptionDefault
exportbooleanThe declaring NgModule exports this directive.false
modulestringThe filename of the declaring NgModule.
namestringThe directive symbol name. Defaults to the last segment of the file path.
prefixstringA prefix to apply to generated selectors.
selectorstringThe HTML selector to use for this directive.
skipFormatbooleanSkip formatting of files.false
skipImportbooleanDo not import this directive into the owning NgModule.false
skipTestsbooleanDo not create “spec.ts” test files for the new class.false
standalonebooleanWhether the generated directive is standalone.true
typestringAppend a custom type to the directive’s filename. It defaults to ‘directive’ for Angular versions below v20. For Angular v20 and above, no type is appended unless specified.

federate-module

Create a federated module, which is exposed by a Producer (remote) and can be subsequently loaded by a Consumer (host).

Usage:

Terminal window
nx generate @nx/angular:federate-module [options]

Arguments:

Terminal window
nx generate @nx/angular:federate-module <path> [options]

Options

OptionTypeDescriptionDefault
namestring [required]The name of the module.
remotestring [required]The name of the Producer (remote).
e2eTestRunnerstringTest runner to use for end to end (e2e) tests of the Producer (remote) if it needs to be created."cypress"
hoststringThe Consumer (host) application for this Producer (remote).
remoteDirectorystringThe directory of the new Producer (remote) application if one needs to be created.
skipFormatbooleanSkip formatting files.false
standalonebooleanWhether to generate the Producer (remote) application with standalone components if it needs to be created.true
stylestringThe file extension to be used for style files for the Producer (remote) if one needs to be created."css"
unitTestRunnerstringTest runner to use for unit tests of the Producer (remote) if it needs to be created."jest"

host

Create an Angular Consumer (Host) Module Federation Application.

Usage:

Terminal window
nx generate @nx/angular:host [options]

Aliases: consumer

Arguments:

Terminal window
nx generate @nx/angular:host <directory> [options]

Options

OptionTypeDescriptionDefault
addTailwindbooleanWhether to configure Tailwind CSS for the application.false
backendProjectstringBackend project that provides data to this application. This sets up proxy.config.json.
bundlerstringThe bundler to use for the host application."webpack"
dynamicbooleanShould the host application use dynamic federation?false
e2eTestRunnerstringTest runner to use for end to end (E2E) tests."playwright"
inlineStylebooleanSpecifies if the style will be in the ts file.false
inlineTemplatebooleanSpecifies if the template will be in the ts file.false
linterstringThe tool to use for running lint checks."eslint"
namestringThe name to give to the Consumer (host) Angular application.
prefixstringThe prefix to apply to generated selectors.
remotesarrayThe names of the Producers (remote) applications to add to the Consumer (host).
serverRoutingbooleanCreates a server application using the Server Routing and App Engine APIs for application using the application builder (Developer Preview). Note: this is only supported in Angular versions 19.x.x. From Angular 20 onwards, SSR will always enable server routing when using the application builder.
setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
skipFormatbooleanSkip formatting files.false
skipPackageJsonbooleanDo not add dependencies to package.json.false
skipPostInstallbooleanDo not add or append ngcc to the postinstall script in package.json.false
skipTestsbooleanSkip creating spec files.false
ssrbooleanWhether to configure SSR for the Consumer (host) applicationfalse
standalonebooleanWhether to generate a Consumer (host) application that uses standalone components.true
strictbooleanCreate an application with stricter type checking and build optimization options.true
stylestringThe file extension to be used for style files."css"
tagsstringAdd tags to the application (used for linting).
typescriptConfigurationbooleanWhether the module federation configuration and webpack configuration files should use TS.true
unitTestRunnerstringTest runner to use for unit tests."jest"
viewEncapsulationstringSpecifies the view encapsulation strategy.

library

Creates an Angular library.

Examples

{% tabs %} {% tab label=“Simple Library” %}

Creates the my-ui-lib library with an ui tag:

Terminal window
nx g @nx/angular:library libs/my-ui-lib --tags=ui

{% /tab %}

{% tab label=“Publishable Library” %}

Creates the my-lib library that can be built producing an output following the Angular Package Format (APF) to be distributed as an NPM package:

Terminal window
nx g @nx/angular:library libs/my-lib --publishable --import-path=@my-org/my-lib

{% /tab %}

{% tab label=“Buildable Library” %}

Creates the my-lib library with support for incremental builds:

Terminal window
nx g @nx/angular:library libs/my-lib --buildable

{% /tab %}

{% tab label=“Nested Folder & Import”%} Creates the my-lib library in the nested directory and sets the import path to @myorg/nested/my-lib:

Terminal window
nx g @nx/angular:library libs/nested/my-lib --importPath=@myorg/nested/my-lib

{% /tab %}

Usage:

Terminal window
nx generate @nx/angular:library [options]

Aliases: lib

Arguments:

Terminal window
nx generate @nx/angular:library <directory> [options]

Options

OptionTypeDescriptionDefault
addModuleSpecbooleanAdd a module spec file.false
addTailwindbooleanWhether to configure Tailwind CSS for the application. It can only be used with buildable and publishable libraries. Non-buildable libraries will use the application’s Tailwind configuration.false
buildablebooleanGenerate a buildable library.false
changeDetectionstringThe change detection strategy to use in the new component. Disclaimer: This option is only valid when --standalone is set to true."Default"
compilationModestringSpecifies the compilation mode to use. If not specified, it will default to partial for publishable libraries and to full for buildable libraries. The full value can not be used for publishable libraries.
displayBlockbooleanSpecifies if the component generated style will contain :host { display: block; }. Disclaimer: This option is only valid when --standalone is set to true.false
flatbooleanEnsure the generated standalone component is not placed in a subdirectory. Disclaimer: This option is only valid when --standalone is set to true.false
importPathstringThe library name used to import it, like @myorg/my-awesome-lib. Must be a valid npm name.
inlineStylebooleanInclude styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file. Disclaimer: This option is only valid when --standalone is set to true.false
inlineTemplatebooleanInclude template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file. Disclaimer: This option is only valid when --standalone is set to true.false
lazybooleanAdd RouterModule.forChild when set to true, and a simple array of routes when set to false.false
linterstringThe tool to use for running lint checks."eslint"
namestringThe name of the library.
parentstringPath to the parent route configuration using loadChildren or children, depending on what lazy is set to.
prefixstringThe prefix to apply to generated selectors.
publishablebooleanGenerate a publishable library.false
routingbooleanAdd router configuration. See lazy for more information.false
selectorstringThe HTML selector to use for this component. Disclaimer: This option is only valid when --standalone is set to true.
setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
simpleNamebooleanDon’t include the directory in the name of the module or standalone component entry of the library.false
skipFormatbooleanSkip formatting files.false
skipModulebooleanWhether to skip the creation of a default module when generating the library.false
skipPackageJsonbooleanDo not add dependencies to package.json.false
skipSelectorbooleanSpecifies if the component should have a selector or not. Disclaimer: This option is only valid when --standalone is set to true.false
skipTestsbooleanDo not create spec.ts test files for the new component. Disclaimer: This option is only valid when --standalone is set to true.false
skipTsConfigbooleanDo not update tsconfig.json for development experience.false
standalonebooleanGenerate a library that uses a standalone component instead of a module as the entry point.true
strictbooleanCreate a library with stricter type checking and build optimization options.true
stylestringThe file extension or preprocessor to use for style files, or none to skip generating the style file. Disclaimer: This option is only valid when --standalone is set to true."css"
tagsstringAdd tags to the library (used for linting).
unitTestRunnerstringTest runner to use for unit tests."jest"
viewEncapsulationstringThe view encapsulation strategy to use in the new component. Disclaimer: This option is only valid when --standalone is set to true.

library-secondary-entry-point

Creates a secondary entry point for an Angular publishable library.

Examples

{% tabs %}

{% tab label=“Basic Usage” %} Create a secondary entrypoint named button in the ui library.

Terminal window
nx g @nx/angular:library-secondary-entry-point --library=ui --name=button

{% /tab %}

{% tab label=“Skip generating module” %} Create a secondary entrypoint named button in the ui library but skip creating an NgModule.

Terminal window
nx g @nx/angular:library-secondary-entry-point --library=ui --name=button --skipModule

{% /tab %}

{% /tabs %}

Usage:

Terminal window
nx generate @nx/angular:library-secondary-entry-point [options]

Aliases: secondary-entry-point, entry-point

Arguments:

Terminal window
nx generate @nx/angular:library-secondary-entry-point <name> [options]

Options

OptionTypeDescriptionDefault
librarystring [required]The name of the library to create the secondary entry point for.
skipFormatbooleanSkip formatting files.false
skipModulebooleanSkip generating a module for the secondary entry point.false

move

Move an Angular project to another folder in the workspace.

Usage:

Terminal window
nx generate @nx/angular:move [options]

Aliases: mv

Arguments:

Terminal window
nx generate @nx/angular:move <destination> [options]

Options

OptionTypeDescriptionDefault
projectNamestring [required]The name of the Angular project to move.
importPathstringThe new import path to use in the tsconfig.base.json.
newProjectNamestringThe new name of the project after the move.
skipFormatbooleanSkip formatting files.false
updateImportPathbooleanUpdate the import path to reflect the new location.true

ngrx

Adds NgRx support to an application or library.

Usage:

Terminal window
nx generate @nx/angular:ngrx [options]

Arguments:

Terminal window
nx generate @nx/angular:ngrx <name> [options]

Options

OptionTypeDescriptionDefault
barrelsbooleanUse barrels to re-export actions, state and selectors.false
directorystringThe name of the folder used to contain/group the generated NgRx files."+state"
facadebooleanCreate a Facade class for the the feature.false
minimalbooleanOnly register the root state management setup or feature state.true
modulestringThe path to the NgModule where the feature state will be registered. The host directory will create/use the new state directory.
parentstringThe path to the file where the state will be registered. For NgModule usage, this will be your app-module.ts for your root state, or your Feature Module for feature state. For Standalone API usage, this will be your app.config.ts file for your root state, or the Routes definition file for your feature state. The host directory will create/use the new state directory.
rootbooleanSetup root or feature state management with NgRx.false
routestringThe route that the Standalone NgRx Providers should be added to."''"
skipFormatbooleanSkip formatting files.false
skipImportbooleanGenerate NgRx feature files without registering the feature in the NgModule.false
skipPackageJsonbooleanDo not update the package.json with NgRx dependencies.false

ngrx-feature-store

Add an NgRx Feature Store to an application or library.

Usage:

Terminal window
nx generate @nx/angular:ngrx-feature-store [options]

Arguments:

Terminal window
nx generate @nx/angular:ngrx-feature-store <name> [options]

Options

OptionTypeDescriptionDefault
barrelsbooleanUse barrels to re-export actions, state and selectors.false
directorystringThe name of the folder used to contain/group the generated NgRx files."+state"
facadebooleanCreate a Facade class for the the feature.false
minimalbooleanOnly register the feature state.false
parentstringThe path to the file where the state will be registered. For NgModule usage, this will be your Feature Module. For Standalone API usage, this will be your Routes definition file for your feature state. The host directory will create/use the new state directory.
routestringThe route that the Standalone NgRx Providers should be added to."''"
skipFormatbooleanSkip formatting files.false
skipImportbooleanGenerate NgRx feature files without registering the feature in the NgModule.false
skipPackageJsonbooleanDo not update the package.json with NgRx dependencies.false

ngrx-root-store

Adds NgRx support to an application.

Usage:

Terminal window
nx generate @nx/angular:ngrx-root-store [options]

Arguments:

Terminal window
nx generate @nx/angular:ngrx-root-store <project> [options]

Options

OptionTypeDescriptionDefault
addDevToolsbooleanInstrument the Store Devtools.false
directorystringThe name of the folder used to contain/group the generated NgRx files."+state"
facadebooleanCreate a Facade class for the the feature.false
minimalbooleanOnly register the root state management setup or also generate a global feature state.true
namestringName of the NgRx state, such as products or users. Recommended to use the plural form of the name.
routestringThe route that the Standalone NgRx Providers should be added to."''"
skipFormatbooleanSkip formatting files.false
skipImportbooleanGenerate NgRx feature files without registering the feature in the NgModule.false
skipPackageJsonbooleanDo not update the package.json with NgRx dependencies.false

pipe

Creates an Angular pipe.

Usage:

Terminal window
nx generate @nx/angular:pipe [options]

Aliases: p

Arguments:

Terminal window
nx generate @nx/angular:pipe <path> [options]

Options

OptionTypeDescriptionDefault
exportbooleanThe declaring NgModule exports this pipe.false
modulestringThe filename of the declaring NgModule.
namestringThe pipe symbol name. Defaults to the last segment of the file path.
skipFormatbooleanSkip formatting of files.false
skipImportbooleanDo not import this pipe into the owning NgModule.false
skipTestsbooleanDo not create “spec.ts” test files for the new pipe.false
standalonebooleanWhether the generated pipe is standalone.true
typeSeparatorstringThe separator character to use before the type within the generated file’s name. For example, if you set the option to ., the file will be named example.pipe.ts. It defaults to ’-’ for Angular v20+. For versions below v20, it defaults to ’.’.

remote

Create an Angular Producer (Remote) Module Federation Application.

Usage:

Terminal window
nx generate @nx/angular:remote [options]

Aliases: producer

Arguments:

Terminal window
nx generate @nx/angular:remote <directory> [options]

Options

OptionTypeDescriptionDefault
addTailwindbooleanWhether to configure Tailwind CSS for the application.false
backendProjectstringBackend project that provides data to this application. This sets up proxy.config.json.
bundlerstringThe bundler to use for the remote application."webpack"
e2eTestRunnerstringTest runner to use for end to end (E2E) tests."playwright"
hoststringThe name of the Consumer (host) app to attach this Producer (remote) app to.
inlineStylebooleanSpecifies if the style will be in the ts file.false
inlineTemplatebooleanSpecifies if the template will be in the ts file.false
linterstringThe tool to use for running lint checks."eslint"
namestringThe name to give to the Producer (remote) Angular app.
portnumberThe port on which this app should be served.
prefixstringThe prefix to apply to generated selectors.
serverRoutingbooleanCreates a server application using the Server Routing and App Engine APIs for application using the application builder (Developer Preview). Note: this is only supported in Angular versions 19.x.x. From Angular 20 onwards, SSR will always enable server routing when using the application builder.
setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
skipFormatbooleanSkip formatting files.false
skipPackageJsonbooleanDo not add dependencies to package.json.false
skipTestsbooleanSkip creating spec files.false
ssrbooleanWhether to configure SSR for the Producer (remote) application to be consumed by a Consumer (host) application using SSR.false
standalonebooleanWhether to generate a Producer (remote) application with standalone components.true
strictbooleanCreate an application with stricter type checking and build optimization options.true
stylestringThe file extension to be used for style files."css"
tagsstringAdd tags to the application (used for linting).
typescriptConfigurationbooleanWhether the module federation configuration and webpack configuration files should use TS.true
unitTestRunnerstringTest runner to use for unit tests."jest"
viewEncapsulationstringSpecifies the view encapsulation strategy.

scam

Creates a new Angular SCAM.

Usage:

Terminal window
nx generate @nx/angular:scam [options]

Arguments:

Terminal window
nx generate @nx/angular:scam <path> [options]

Options

OptionTypeDescriptionDefault
changeDetectionstringThe change detection strategy to use in the new component."Default"
displayBlockbooleanSpecifies if the style will contain :host { display: block; }.false
exportbooleanSpecifies if the SCAM should be exported from the project’s entry point (normally index.ts). It only applies to libraries.true
inlineScambooleanCreate the NgModule in the same file as the component.true
inlineStylebooleanInclude styles inline in the component.ts file. Only CSS styles can be included inline. By default, an external styles file is created and referenced in the component.ts file.false
inlineTemplatebooleanInclude template inline in the component.ts file. By default, an external template file is created and referenced in the component.ts file.false
namestringThe component symbol name. Defaults to the last segment of the file path.
prefixstringThe prefix to apply to the generated component selector.
selectorstringThe HTML selector to use for this component.
skipFormatbooleanSkip formatting files.false
skipSelectorbooleanSpecifies if the component should have a selector or not.false
skipTestsbooleanDo not create spec.ts test files for the new component.false
stylestringThe file extension or preprocessor to use for style files, or ‘none’ to skip generating the style file."css"
typestringAppend a custom type to the component’s filename. It defaults to ‘component’ for Angular versions below v20. For Angular v20 and above, no type is appended unless specified.
viewEncapsulationstringThe view encapsulation strategy to use in the new component.

scam-directive

Creates a new, generic Angular directive definition in the given or default project.

Usage:

Terminal window
nx generate @nx/angular:scam-directive [options]

Arguments:

Terminal window
nx generate @nx/angular:scam-directive <path> [options]

Options

OptionTypeDescriptionDefault
exportbooleanSpecifies if the SCAM should be exported from the project’s entry point (normally index.ts). It only applies to libraries.true
inlineScambooleanCreate the NgModule in the same file as the Directive.true
namestringThe directive symbol name. Defaults to the last segment of the file path.
prefixstringThe prefix to apply to the generated directive selector.
selectorstringThe HTML selector to use for this directive.
skipFormatbooleanSkip formatting files.false
skipTestsbooleanDo not create spec.ts test files for the new directive.false
typestringAppend a custom type to the directive’s filename. It defaults to ‘directive’ for Angular versions below v20. For Angular v20 and above, no type is appended unless specified.

scam-pipe

Creates a new, generic Angular pipe definition in the given or default project.

Usage:

Terminal window
nx generate @nx/angular:scam-pipe [options]

Arguments:

Terminal window
nx generate @nx/angular:scam-pipe <path> [options]

Options

OptionTypeDescriptionDefault
exportbooleanSpecifies if the SCAM should be exported from the project’s entry point (normally index.ts). It only applies to libraries.true
inlineScambooleanCreate the NgModule in the same file as the Pipe.true
namestringThe pipe symbol name. Defaults to the last segment of the file path.
skipFormatbooleanSkip formatting files.false
skipTestsbooleanDo not create spec.ts test files for the new pipe.false
typeSeparatorstringThe separator character to use before the type within the generated file’s name. For example, if you set the option to ., the file will be named example.pipe.ts. It defaults to ’-’ for Angular v20+. For versions below v20, it defaults to ’.’.

scam-to-standalone

Convert an Inline SCAM to a Standalone Component.

Examples

{% tabs %}

{% tab label=“Basic Usage” %}

This generator allows you to convert an Inline SCAM to a Standalone Component. It’s important that the SCAM you wish to convert has it’s NgModule within the same file for the generator to be able to correctly convert the component to Standalone.

Terminal window
nx g @nx/angular:scam-to-standalone --component=libs/mylib/src/lib/myscam/myscam.ts --project=mylib

{% /tab %}

{% /tabs %}

Usage:

Terminal window
nx generate @nx/angular:scam-to-standalone [options]

Arguments:

Terminal window
nx generate @nx/angular:scam-to-standalone <component> [options]

Options

OptionTypeDescriptionDefault
projectstringThe project containing the SCAM.
skipFormatbooleanSkip formatting the workspace after the generator completes.

setup-mf

Create Module Federation configuration files for given Angular Application.

Examples

The setup-mf generator is used to add Module Federation support to existing applications.

{% tabs %}

{% tab label=“Convert to Host” %} To convert an existing application to a host application, run the following

Terminal window
nx g setup-mf myapp --mfType=host --routing=true

{% /tab %}

{% tab label=“Convert to Remote” %} To convert an existing application to a remote application, run the following

Terminal window
nx g setup-mf myapp --mfType=remote --routing=true

{% /tab %}

{% tab label=“Convert to Remote and attach to a host application” %} To convert an existing application to a remote application and attach it to an existing host application name myhostapp, run the following

Terminal window
nx g setup-mf myapp --mfType=remote --routing=true --host=myhostapp

{% /tab %}

{% tab label=“Convert to Host and attach to existing remote applications” %} To convert an existing application to a host application and attaching existing remote applications named remote1 and remote2, run the following

Terminal window
nx g setup-mf myapp --mfType=host --routing=true --remotes=remote1,remote2

{% /tab %}

{% /tabs %}

Usage:

Terminal window
nx generate @nx/angular:setup-mf [options]

Arguments:

Terminal window
nx generate @nx/angular:setup-mf <appName> [options]

Options

OptionTypeDescriptionDefault
mfTypestring [required]Type of application to generate the Module Federation configuration for."remote"
e2eProjectNamestringThe project name of the associated E2E project for the application. This is only required for Cypress E2E projects that do not follow the naming convention <appName>-e2e.
federationTypestringUse either Static or Dynamic Module Federation pattern for the application."static"
hoststringThe name of the host application that the remote application will be consumed by.
portnumberThe port at which the remote application should be served.
prefixstringThe prefix to use for any generated component.
remotesarrayA list of remote application names that the Consumer (host) application should consume.
routingbooleanGenerate a routing setup to allow a Consumer (host) application to route to the Producer (remote) application.
setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
skipE2EbooleanDo not set up E2E related config.false
skipFormatbooleanSkip formatting the workspace after the generator completes.
skipPackageJsonbooleanDo not add dependencies to package.json.false
standalonebooleanWhether the application is a standalone application.true
typescriptConfigurationbooleanWhether the module federation configuration and webpack configuration files should use TS.true

setup-ssr

Create the additional configuration required to enable SSR via Angular Universal for an Angular application.

Usage:

Terminal window
nx generate @nx/angular:setup-ssr [options]

Arguments:

Terminal window
nx generate @nx/angular:setup-ssr <project> [options]

Options

OptionTypeDescriptionDefault
hydrationbooleanSet up Hydration for the SSR application.true
mainstringThe name of the main entry-point file."main.server.ts"
rootModuleClassNamestringThe name of the root module class."AppServerModule"
rootModuleFileNamestringThe name of the root module file"app.server.module.ts"
serverFileNamestringThe name of the Express server file."server.ts"
serverPortnumberThe port for the Express server.4000
serverRoutingbooleanCreates a server application using the Server Routing and App Engine APIs for application using the application builder (Developer Preview). Note: this is only supported in Angular versions 19.x.x. From Angular 20 onwards, SSR will always enable server routing when using the application builder.
skipFormatbooleanSkip formatting the workspace after the generator completes.
skipPackageJsonbooleanDo not add dependencies to package.json.false
standalonebooleanUse Standalone Components to bootstrap SSR.

setup-tailwind

Adds the Tailwind CSS configuration files for a given Angular project and installs, if needed, the packages required for Tailwind CSS to work.

Examples

The setup-tailwind generator can be used to add Tailwind configuration to apps and publishable libraries.

{% tabs %}

{% tab label=“Standard Setup” %}

To generate a standard Tailwind setup, just run the following command.

Terminal window
nx g @nx/angular:setup-tailwind myapp

{% /tab %}

{% tab label=“Specifying the Styles Entrypoint” %}

To specify the styles file that should be used as the entrypoint for Tailwind, simply pass the --stylesEntryPoint flag, relative to workspace root.

Terminal window
nx g @nx/angular:setup-tailwind myapp --stylesEntryPoint=apps/myapp/src/styles.css

{% /tab %}

{% /tabs %}

Usage:

Terminal window
nx generate @nx/angular:setup-tailwind [options]

Arguments:

Terminal window
nx generate @nx/angular:setup-tailwind <project> [options]

Options

OptionTypeDescriptionDefault
buildTargetstringThe name of the target used to build the project. This option only applies to buildable/publishable libraries."build"
skipFormatbooleanSkips formatting the workspace after the generator completes.
skipPackageJsonbooleanDo not add dependencies to package.json.false
stylesEntryPointstringPath to the styles entry point relative to the workspace root. If not provided the generator will do its best to find it and it will error if it can’t. This option only applies to applications.

stories

Creates Storybook stories/specs for all Angular components declared in a project.

This generator will generate stories for all your components in your project. The stories will be generated using Component Story Format 3 (CSF3).

Terminal window
nx g @nx/angular:stories project-name

You can read more about how this generator works, in the Storybook for Angular overview page.

When running this generator, you will be prompted to provide the following:

You must provide a name for the generator to work.

By default, this generator will also set up Storybook interaction tests. If you don’t want to set up Storybook interaction tests, you can pass the --interactionTests=false option, but it’s not recommended.

There are a number of other options available. Let’s take a look at some examples.

Examples

Ignore certain paths when generating stories

Terminal window
nx g @nx/angular:stories ui --ignorePaths=libs/ui/src/not-stories/**,**/**/src/**/*.other.*

This will generate stories for all the components in the ui project, except for the ones in the libs/ui/src/not-stories directory, and also for components that their file name is of the pattern *.other.*.

This is useful if you have a project that contains components that are not meant to be used in isolation, but rather as part of a larger component.

By default, Nx will ignore the following paths:

*.stories.ts, *.stories.tsx, *.stories.js, *.stories.jsx, *.stories.mdx

but you can change this behaviour easily, as explained above.

Usage:

Terminal window
nx generate @nx/angular:stories [options]

Arguments:

Terminal window
nx generate @nx/angular:stories <name> [options]

Options

OptionTypeDescriptionDefault
ignorePathsarrayPaths to ignore when looking for components.["*.stories.ts,*.stories.tsx,*.stories.js,*.stories.jsx,*.stories.mdx"]
interactionTestsbooleanSet up Storybook interaction tests.true
skipFormatbooleanSkip formatting files.false

storybook-configuration

Adds Storybook configuration to a project to be able to use and create stories.

This generator will set up Storybook for your Angular project. By default, starting Nx 16, Storybook v7 is used.

Terminal window
nx g @nx/angular:storybook-configuration project-name

You can read more about how this generator works, in the Storybook for Angular overview page.

When running this generator, you will be prompted to provide the following:

  • The name of the project you want to generate the configuration for.
  • Whether you want to set up Storybook interaction tests (interactionTests). If you choose yes, a play function will be added to your stories, and all the necessary dependencies will be installed. Also, a test-storybook target will be generated in your project’s project.json, with a command to invoke the Storybook test-runner. You can read more about this in the Nx Storybook interaction tests documentation page.
  • Whether you want to generateStories for the components in your project. If you choose yes, a .stories.ts file will be generated next to each of your components in your project.

You must provide a name for the generator to work.

By default, this generator will also set up Storybook interaction tests. If you don’t want to set up Storybook interaction tests, you can pass the --interactionTests=false option, but it’s not recommended.

There are a number of other options available. Let’s take a look at some examples.

Examples

Generate Storybook configuration

Terminal window
nx g @nx/angular:storybook-configuration ui

This will generate Storybook configuration for the ui project using TypeScript for the Storybook configuration files (the files inside the .storybook directory, eg. .storybook/main.ts).

Ignore certain paths when generating stories

Terminal window
nx g @nx/angular:storybook-configuration ui --generateStories=true --ignorePaths=libs/ui/src/not-stories/**,**/**/src/**/*.other.*,apps/my-app/**/*.something.ts

This will generate a Storybook configuration for the ui project and generate stories for all components in the libs/ui/src/lib directory, except for the ones in the libs/ui/src/not-stories directory, and the ones in the apps/my-app directory that end with .something.ts, and also for components that their file name is of the pattern *.other.*.

This is useful if you have a project that contains components that are not meant to be used in isolation, but rather as part of a larger component.

By default, Nx will ignore the following paths:

*.stories.ts, *.stories.tsx, *.stories.js, *.stories.jsx, *.stories.mdx

but you can change this behaviour easily, as explained above.

Generate Storybook configuration using JavaScript

Terminal window
nx g @nx/angular:storybook-configuration ui --tsConfiguration=false

By default, our generator generates TypeScript Storybook configuration files. You can choose to use JavaScript for the Storybook configuration files of your project (the files inside the .storybook directory, eg. .storybook/main.js).

Usage:

Terminal window
nx generate @nx/angular:storybook-configuration [options]

Arguments:

Terminal window
nx generate @nx/angular:storybook-configuration <project> [options]

Options

OptionTypeDescriptionDefault
configureStaticServebooleanSpecifies whether to configure a static file server target for serving storybook. Helpful for speeding up CI build/test times.true
generateStoriesbooleanSpecifies whether to automatically generate *.stories.ts files for components declared in this project or not.true
ignorePathsarrayPaths to ignore when looking for components.["*.stories.ts,*.stories.tsx,*.stories.js,*.stories.jsx,*.stories.mdx"]
interactionTestsbooleanSet up Storybook interaction tests.true
linterstringThe tool to use for running lint checks."eslint"
skipFormatbooleanSkip formatting files.false
tsConfigurationbooleanConfigure your project with TypeScript. Generate main.ts and preview.ts files, instead of main.js and preview.js.true

web-worker

Creates a new, generic web worker definition in the given or default project.

Examples

{% tabs %}

{% tab label=“Simple Usage” %}

The basic usage of the web-worker generator is defined below. You must provide a name for the web worker and the project to assign it to.

Terminal window
nx g @nx/angular:web-worker myWebWorker --project=myapp

{% /tab %}

{% /tabs %}

Usage:

Terminal window
nx generate @nx/angular:web-worker [options]

Arguments:

Terminal window
nx generate @nx/angular:web-worker <name> [options]

Options

OptionTypeDescriptionDefault
projectstring [required]The name of the project.
pathstringThe path at which to create the worker file, relative to the current workspace.
skipFormatbooleanSkip formatting files.false
snippetbooleanAdd a worker creation snippet in a sibling file of the same name.true
## Getting Help
You can get help for any generator by adding the `--help` flag:
```bash
nx generate @nx/angular:<generator> --help
```