Code Generators & Workspace Automation
Write custom Nx generators to scaffold components, pages, and libraries consistently.
What Are Nx Generators?
Nx generators are code generation tools (like schematics) that scaffold files, update configs, and maintain consistency across a monorepo. Run built-in generators or write your own.
Running Built-in Generators
Use nx generate with a generator package and name. Add --dry-run to preview changes without writing files.
# Generate a React component in the ui library:
npx nx generate @nx/react:component Button --project=ui --dry-run
# Generate a hook:
npx nx generate @nx/react:hook useAuth --project=data-accessAll lessons in this course
- Creating an Nx Monorepo with React Apps
- Shared Libraries & Internal Packages
- Nx Affected Commands & Caching
- Code Generators & Workspace Automation