Skip to content

@nx/react-native - Generators

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

For an overview of the plugin and setup instructions, see the @nx/react-native introduction.

Create a React Application for Nx.

Usage:

Terminal window
nx generate @nx/react-native:application [options]

Aliases: app

Arguments:

Terminal window
nx generate @nx/react-native:application <directory> [options]
OptionTypeDescriptionDefault
--bundlerstringThe bundler to use."vite"
--displayNamestringThe display name to show in the application. Defaults to name.
--e2eTestRunnerstringAdds the specified e2e test runner."none"
--enableTypedLintingbooleanWhether to enable typed linting. For flat configs, this configures the recommended parserOptions.projectService and tsconfigRootDir. For legacy .eslintrc configs, this configures parserOptions.project. We do not enable this by default for lint performance reasons.false
--installbooleanRuns pod install for native modules before building iOS app.true
--jsbooleanGenerate JavaScript files rather than TypeScript filesfalse
--linterstringThe tool to use for running lint checks."none"
--namestringThe name of the application.
--setParserOptionsProjectbooleanDeprecated alias for enableTypedLinting.false
--skipFormatbooleanSkip formatting filesfalse
--skipPackageJsonbooleanDo not add dependencies to package.json.false
--tagsstringAdd tags to the application (used for linting).
--unitTestRunnerstringTest runner to use for unit tests"none"
--useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

Create a React native Component for Nx.

Usage:

Terminal window
nx generate @nx/react-native:component [options]

Aliases: c

Arguments:

Terminal window
nx generate @nx/react-native:component <path> [options]
OptionTypeDescriptionDefault
--classComponentbooleanUse class components instead of functional component.false
--exportbooleanWhen true, the component is exported from the project index.ts (if it exists).false
--namestringThe component symbol name. Defaults to the last segment of the file path.
--skipFormatbooleanSkip formatting files.false
--skipTestsbooleanWhen true, does not create spec.ts test files for the new component.false

Convert existing React Native project(s) using @nx/react-native:* executors to use @nx/react-native/plugin. Defaults to migrating all projects. Pass ‘—project’ to migrate only one target.

Usage:

Terminal window
nx generate @nx/react-native:convert-to-inferred [options]
OptionTypeDescriptionDefault
--projectstringThe project to convert from using the @nx/react-native:* executors to use @nx/react-native/plugin.
--skipFormatbooleanWhether to format files at the end of the migration.false

Create a React Native Library for Nx.

Usage:

Terminal window
nx generate @nx/react-native:library [options]

Aliases: lib

Arguments:

Terminal window
nx generate @nx/react-native:library <directory> [options]
OptionTypeDescriptionDefault
--buildablebooleanGenerate a buildable library.false
--enableTypedLintingbooleanWhether to enable typed linting. For flat configs, this configures the recommended parserOptions.projectService and tsconfigRootDir. For legacy .eslintrc configs, this configures parserOptions.project. We do not enable this by default for lint performance reasons.false
--importPathstringThe library name used to import it, like @myorg/my-awesome-lib.
--jsbooleanGenerate JavaScript files rather than TypeScript files.false
--linterstringThe tool to use for running lint checks."none"
--namestringLibrary name.
--publishablebooleanCreate a publishable library.
--setParserOptionsProjectbooleanDeprecated alias for enableTypedLinting.false
--skipFormatbooleanSkip formatting files.false
--skipPackageJsonbooleanDo not add dependencies to package.json.false
--skipTsConfigbooleanDo not update tsconfig.json for development experience.false
--strictbooleanWhether to enable tsconfig strict mode or not.true
--tagsstringAdd tags to the library (used for linting).
--unitTestRunnerstringTest runner to use for unit tests."none"
--useProjectJsonbooleanUse a project.json configuration file instead of inlining the Nx configuration in the package.json file.

Setup web configuration to React Native apps using react-native-web.

Usage:

Terminal window
nx generate @nx/react-native:web-configuration [options]

Arguments:

Terminal window
nx generate @nx/react-native:web-configuration <project> [options]
OptionTypeDescriptionDefault
--bundlerstring [required]The bundler to use."vite"
--skipFormatbooleanSkip formatting files.false
--skipPackageJsonbooleanDo not add dependencies to package.json.false

You can get help for any generator by adding the --help flag:

Terminal window
nx generate @nx/react-native:<generator> --help