Create React App is a command-line tool that generates React applications with pre-configured build setup, eliminating the need for manual webpack, Babel, and other tooling configuration. It provides a zero-configuration development environment with hot reloading, testing, and optimized production builds, allowing developers to start building React applications immediately.
npm install -g create-react-app or use with npxFor programmatic usage (available exports):
// Import from the main createReactApp.js module
const { init, getTemplateInstallPackage } = require("create-react-app/createReactApp");
// Note: The main index.js simply calls init() and is primarily for CLI usage
// Direct module.exports from createReactApp.js:
// { init, getTemplateInstallPackage }Command Line Usage (Primary Interface):
# Create a new React app
npx create-react-app my-app
# Create with TypeScript template
npx create-react-app my-app --template typescript
# Create with custom template
npx create-react-app my-app --template cra-template-pwa
# Show environment information
npx create-react-app --info
# Verbose output
npx create-react-app my-app --verboseProgrammatic Usage:
const { init } = require("create-react-app/createReactApp");
// Initialize create-react-app (processes command line arguments)
init();Main command-line interface for creating React applications.
/**
* Command-line interface with the following signature:
* create-react-app <project-directory> [options]
*/
interface CLIOptions {
/** Project directory name (required) */
projectDirectory: string;
/** Print additional logs during creation */
verbose?: boolean;
/** Print environment debug information */
info?: boolean;
/** Use non-standard version of react-scripts */
scriptsVersion?: string;
/** Specify template for the created project */
template?: string;
/** Enable Yarn Plug'n'Play (deprecated) */
usePnp?: boolean;
}Main programmatic entry point that processes command-line arguments and orchestrates app creation.
/**
* Initialize create-react-app CLI processing
* Reads from process.argv, shows deprecation warning, and executes the app creation workflow
* Performs version checking against npm registry and warns if outdated
* Handles --info flag to display environment information
* Handles --help flag to show usage information
* @returns {void | Promise<void>} Returns void for synchronous operations, Promise for async operations like environment info display
*/
function init(): void | Promise<void>;Automatic version validation against npm registry with fallback mechanisms.
/**
* Check for latest version of create-react-app on npm registry
* Falls back to 'npm view create-react-app version' if direct API fails
* Used internally by init() to warn users of outdated versions
* @returns {Promise<string|null>} Promise resolving to latest version string or null if unavailable
*/
function checkForLatestVersion(): Promise<string | null>;Resolves template names to installable package names with proper cra-template prefix handling.
/**
* Resolve template package names for installation
* Automatically adds 'cra-template-' prefix to template names when needed
* Handles local paths (file:), URLs, and scoped packages
* @param {string} [template] - Template name, path, or URL. Defaults to 'cra-template' if not specified
* @param {string} originalDirectory - Original working directory path for resolving relative file paths
* @returns {Promise<string>} Promise resolving to installable package name with proper prefixes
*/
function getTemplateInstallPackage(
template?: string,
originalDirectory: string
): Promise<string>;<project-directory>: Name or path for the new React project directory.
--verbose: Enable verbose logging during project creation, showing detailed output from npm/yarn installation and setup processes.
--info: Display comprehensive environment information including:
Output is formatted using the envinfo library with duplicates shown and missing packages indicated.
--scripts-version <alternative-package>: Specify non-standard version of react-scripts. Accepts:
0.8.2@nextmy-react-scriptsfile:../my-react-scriptshttps://example.com/my-react-scripts.tgz--template <path-to-template>: Specify template for project creation. Accepts:
typescript, cra-template-pwa@company/cra-template-customfile:../my-templatehttps://example.com/template.tar.gz--use-pnp: Enable Yarn Plug'n'Play (deprecated in newer versions).
Create React App automatically resolves template names using the following patterns:
/**
* Template resolution examples based on actual implementation:
*/
interface TemplateResolution {
// Input -> Resolved Package Name
"typescript": "cra-template-typescript"; // Adds prefix to simple names
"cra-template": "cra-template"; // Preserves existing cra-template prefix
"cra-template-typescript": "cra-template-typescript"; // No change needed
"@scope/template": "@scope/cra-template-template"; // Adds prefix to scoped packages
"@scope/cra-template": "@scope/cra-template"; // Preserves existing prefix in scoped packages
"@scope/cra-template-typescript": "@scope/cra-template-typescript"; // No change for complete scoped names
"file:../my-template": "file:/absolute/path/to/my-template"; // Resolves relative file paths to absolute
"https://example.com/template.tgz": "https://example.com/template.tgz"; // URLs and archives pass through unchanged
"my-template.tar.gz": "my-template.tar.gz"; // Archive files pass through unchanged
"@next": "@next/cra-template"; // Version-only input gets default template name
}Create React App generates the following standard project structure:
my-app/
├── public/
│ ├── index.html
│ └── manifest.json
├── src/
│ ├── App.js
│ ├── App.test.js
│ ├── index.js
│ └── index.css
├── package.json
└── README.mdinterface SystemRequirements {
/** Minimum Node.js version */
nodeVersion: ">=14.0.0";
/** Supported package managers */
packageManagers: ["npm", "yarn"];
/** Minimum npm version for full feature support */
npmVersion: ">=6.0.0";
/** Minimum Yarn version for PnP support (deprecated) */
yarnPnpVersion: ">=1.12.0";
}The tool handles several error scenarios:
Create React App installs the following core dependencies in created projects:
interface ProjectDependencies {
/** Core React library */
react: string;
/** React DOM rendering */
"react-dom": string;
/** Build scripts and development server */
"react-scripts": string;
/** Optional: Template-specific dependencies */
[templateDependency: string]: string;
}As of version 5.1.0, Create React App shows a deprecation warning directing users to modern React frameworks. The warning is displayed once per install and includes:
The tool continues to function but recommends exploring alternatives listed on react.dev.