Skip to content

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

application

Create a web application using swc or babel as compiler.

Examples

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

Create an application named my-app:

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

{% /tab %}

{% tab label=“Application using Vite as bundler” %}

Create an application named my-app:

Terminal window
nx g @nx/web:app apps/my-app --bundler=vite

When choosing vite as the bundler, your unit tests will be set up with vitest, unless you choose none for unitTestRunner.

{% /tab %}

{% tab label=“In a nested directory” %}

Create an application named my-app in the my-dir directory:

Terminal window
nx g @nx/web:app apps/my-dir/my-app

{% /tab %}

{% tab label=“Add tags” %}

Add tags to the application (used for linting).

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

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

Usage:

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

Aliases: app

Arguments:

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

Options

OptionTypeDescriptionDefault
bundlerstringThe bundler to use."vite"
compilerstringThe compiler to use"swc"
e2eTestRunnerstringTest runner to use for end to end (e2e) tests"playwright"
inSourceTestsbooleanWhen using Vitest, separate spec files will not be generated and instead will be included within the source files.false
linterstringThe tool to use for running lint checks."none"
namestringThe name of the application.
setParserOptionsProjectbooleanWhether or not to configure the ESLint parserOptions.project option. We do not do this by default for lint performance reasons.false
skipFormatbooleanSkip formatting filesfalse
strictbooleanCreates an application with strict mode and strict type checking.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. Default value is ‘jest’ when using ‘webpack’ or ‘none’ as the bundler and ‘vitest’ when using ‘vite’ as the bundler"none"
useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

static-config

Add a new serve target to serve a build apps static files. This allows for faster serving of the static build files by reusing the case. Helpful when reserving the app over and over again like in e2e tests.

Usage:

Terminal window
nx generate @nx/web:static-config [options]

Options

OptionTypeDescriptionDefault
buildTargetstring [required]Name of the build target to serve
outputPathstringPath to the directory of the built files. This is only needed if buildTarget doesn’t specify an outputPath executor option.
spabooleanWhether to set the ‘spa’ flag on the generated target.true
targetNamestringName of the serve target to add. Defaults to ‘serve-static’."serve-static"
## Getting Help
You can get help for any generator by adding the `--help` flag:
```bash
nx generate @nx/web:<generator> --help
```