React Native CLI comes with following commands:
bundle
clean
config
doctor
init
info
log-android
log-ios
ram-bundle
run-android
build-android
run-ios
build-ios
start
upgrade
profile-hermes
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@react-native-community/cli
orreact-native
package 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@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.
Shortcut for --template react-native@version
.
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/repo
format)
Example:
npx react-native@latest init MyApp --template react-native-custom-template
npx react-native@latest init MyApp --template file:///Users/name/template-path
npx react-native@latest init MyApp --template file:///Users/name/template-name-1.0.0.tgz
npx react-native@latest init MyApp --template Esemesek/react-native-new-template
A 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
Force use of npm during initialization
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
Usage:
npx react-native upgrade
This command generates a relevant link to the Upgrade Helper to help you upgrade manually.