React Native CLI comes with following commands:
bundlecleanconfigdoctorlink-assetsinitinfolog-androidlog-iosrun-androidbuild-androidrun-iosbuild-iosstart
Available since 0.60.0
IMPORTANT: Please note that this command is not available through
react-native-cli, hence you need to either invoke it directly from the@react-native-community/clipackage which proxies binary to this CLI since 0.60.0, so it's possible to use it with e.g.npx.
Usage (with npx):
npx @react-native-community/cli@latest init <projectName> [options]Initialize a new React Native project named in a directory of the same name. You can find out more use cases in init docs.
The version of React Native to use with the template.
Uses a custom directory instead of <projectName>.
Uses a custom app title instead of <projectName>.
Uses a custom template. Accepts following template sources:
- an npm package name
- an absolute path to a local directory
- an absolute path to a tarball created using
npm pack - link to a GitHub repository (supports
username/repoformat)
Example:
npx react-native-community/cli@latest init MyApp --template react-native-community/cli-custom-template
npx react-native-community/cli@latest init MyApp --template file:///Users/name/template-path
npx react-native-community/cli@latest init MyApp --template file:///Users/name/template-name-1.0.0.tgz
npx react-native-community/cli@latest init MyApp --template Esemesek/react-native-community/cli-new-template
# Use a specific version of the community template with the nightly release of React Native
npx react-native-community/cli@latest init MyApp --template @react-native-community/template0.74.0 --version nightlyA template is any directory or npm package that contains a template.config.js file in the root with the following type:
type Template = {
// Placeholder used to rename and replace in files
// package.json, index.json, android/, ios/
placeholderName: string;
// Directory with template
templateDir: string;
// Path to script, which will be executed after init
postInitScript?: string;
// Placeholder used to rename app title inside values.xml and Info.plist
titlePlaceholder?: string;
};Example template.config.js:
module.exports = {
placeholderName: 'ProjectName',
titlePlaceholder: 'Project Display Name',
templateDir: './template',
postInitScript: './script.js',
};Skip dependencies installation
Determine if CocoaPods should be installed when initializing a project. If set to true it will install pods, if set to false, it will skip the step entirely. If not used, prompt will be displayed
Use specific package manager to initialize the project. Available options: yarn, npm, bun. Default: yarn
Create project with custom package name for Android and bundle identifier for iOS. The correct package name should:
- contain at least two segments separated by dots, e.g.
com.example - contain only alphanumeric characters and dots
Skip git repository initialization.
Replaces the directory if it already exists
Passes extra options that will be added to .yarnrc.yml file, format: key=value,key2=value2.