- ReactJS - Discussion
- ReactJS - Useful Resources
- ReactJS - Quick Guide
- ReactJS - Example
- ReactJS - Building and Deployment
- ReactJS - CLI Commands
- ReactJS - Testing
- ReactJS - Animation
- ReactJS - Redux
- ReactJS - Routing
- ReactJS - Form programming
- ReactJS - Http client programming
- ReactJS - State Management
- ReactJS - Event management
- ReactJS - Properties (props)
- ReactJS - Styling
- ReactJS - Components
- ReactJS - JSX
- ReactJS - Creating a React Application
- ReactJS - Architecture
- ReactJS - Installation
- ReactJS - Introduction
- ReactJS - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
ReactJS - CLI Commands
Let us learn the basic command available in Create React App command pne apppcation in this chapter.
Creating a new apppcation
Create React App provides multiple ways to create React apppcation.
Using npx script.
npx create-react-app <react-app-name> npx create-react-app hello-react-app
Using npm package manager.
npm init react-app <react-app-name> npm init react-app hello-react-app
Using yarn package manager.
yarn init react-app <react-app-name> yarn init react-app hello-react-app
Selecting a template
Create React App creates React apppcation using default template. Template refers the initial code with certain build-in functionapty. There are hundreds of template with many advanced features are available in npm package server. Create React App allows the users to select the template through –template command pne switch.
create-react-app my-app --template typescript
Above command will create react app using cra-template-typescript package from npm server.
Instalpng a dependency
React dependency package can be installed using normal npm or yarn package command as React uses the project structure recommended by npm and yarn.
Using npm package manager.
npm install --save react-router-dom
Using yarn package manager.
yarn add react-router-dom
Running the apppcation
React apppcation can be started using npm or yarn command depending on the package manager used in the project.
Using npm package manager.
npm start
Using yarn package manager.
yarn start
To run the apppcation in secure mode (HTTPS), set an environment variable, HTTPS and set it to true before starting the apppcation. For example, in windows command prompt (cmd.exe), the below command set HTTPS and starts the apppcation is HTTPS mode.
set HTTPS=true && npm startAdvertisements