Command line tools to interact with React Native projects
npx @tessl/cli install tessl/npm-react-native-community--cli@20.0.0React Native CLI is the official command-line interface for React Native development. It provides essential commands for project initialization, configuration management, debugging, and development workflow automation. The CLI serves as both a programmatic API and a comprehensive set of command-line tools that handle the complete React Native development lifecycle.
npm install @react-native-community/cliimport { run, loadConfig, loadConfigAsync, createDevServerMiddleware, bin } from "@react-native-community/cli";For CommonJS:
const { run, loadConfig, loadConfigAsync, createDevServerMiddleware, bin } = require("@react-native-community/cli");import { run, loadConfigAsync } from "@react-native-community/cli";
// Load React Native project configuration
const config = await loadConfigAsync();
console.log("Project root:", config.root);
console.log("Available platforms:", Object.keys(config.platforms));
// Run CLI programmatically (typically not needed)
await run();# Initialize a new React Native project
npx react-native init MyApp
# Get project information
npx react-native info
# Clean project caches
npx react-native clean
# Display current configuration
npx react-native config
# Run diagnostics and fix issues
npx react-native doctorThe React Native CLI is built around several key components:
Core programmatic interface for running the CLI, loading configurations, and integrating with development tools.
function run(platformName?: string): Promise<void>;
function loadConfig(): Config;
function loadConfigAsync(options?: {selectedPlatform?: string}): Promise<Config>;
function createDevServerMiddleware(options: MiddlewareOptions): DevServerMiddleware;Complete command-line interface providing project initialization, configuration management, diagnostics, and maintenance tools.
// Project Commands (require React Native project)
type ProjectCommand = "config" | "clean" | "info";
// Detached Commands (work standalone)
type DetachedCommand = "init" | "doctor";Comprehensive type system covering CLI configuration, commands, platform definitions, and development tool integration.
interface Config {
root: string;
reactNativePath: string;
platforms: Record<string, PlatformConfig>;
commands: Command[];
dependencies: Record<string, DependencyConfig>;
}
interface Command<IsDetached extends boolean = boolean> {
name: string;
description?: string;
func: IsDetached extends true ? DetachedCommandFunction : CommandFunction;
detached?: IsDetached;
options?: CommandOption[];
examples?: Array<{desc: string; cmd: string}>;
}