Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/nrwl/nx/llms.txt

Use this file to discover all available pages before exploring further.

nx generate <generator> [options]
Alias: nx g nx generate runs a generator to create, modify, or delete files in your workspace. Generators are provided by Nx plugins (e.g., @nx/react, @nx/js) and can also be defined locally in your workspace.

Arguments

generator
string
required
The generator to run, in the format collection:generator (e.g., @nx/react:application) or just generator if the collection can be inferred.

Options

--dry-run
boolean
default:"false"
Preview the file changes that would be made without actually writing them to disk. Alias: -d. Also enabled by setting NX_DRY_RUN=true.
--interactive
boolean
default:"true"
When false, disables interactive input prompts for generator options. All required options must be provided as flags. Also controlled by NX_INTERACTIVE=false.
--quiet
boolean
Hides logs from file system operations (e.g., CREATE package.json). Cannot be used together with --verbose.
--verbose
boolean
Prints additional information about the generation process, including stack traces on error. Cannot be used together with --quiet.

Listing available generators

Use nx list to discover generators from installed plugins:
# List all installed plugins and their generators
nx list

# List generators for a specific plugin
nx list @nx/react
nx list @nx/js
To see the options for a specific generator, pass --help after the generator name:
nx g @nx/react:application --help
nx g @nx/js:library --help

Examples

nx generate @nx/react:application myapp
Generator options vary by plugin and generator. Always check the generator’s schema with --help before running.

Workspace generators

You can define your own generators locally in tools/generators. Run them by their name without a collection prefix:
nx generate my-local-generator --name=foo
Or with the local plugin collection:
nx g @my-org/workspace-plugin:my-generator