How to Install React.js

How to Install React.js

There are different way to install and Use Reactjs in new or existing project.

Please visit mobiosolutions.com for React.js project development.

1.Add React to a New Application

The easiest way to get started on a new React project is by using a starter kit.

Create React App

Create React App is the best way to start building a new React single page application. It sets up your development environment so that you can use the latest JavaScript features, provides a nice developer experience, and optimizes your app for production. You’ll need to have Node >= 6 on your machine.

User below command to create react project

npm install -g create-react-app
create-react-app my-app

cd my-app
npm start

If you have npm 5.2.0+ installed, you may use npx instead.

npx create-react-app my-app

cd my-app
npm start

Create React App doesn’t handle backend logic or databases; it just creates a frontend build pipeline, so you can use it with any backend you want. It uses build tools like Babel and webpack under the hood, but works with zero configuration.

When you’re ready to deploy to production, running npm run build will create an optimized build of your app in the build folder. You can learn more about Create React App from its README and the User Guide.

2.CDN Links

The UMD builds of React and ReactDOM are available over a CDN.

<script crossorigin src="https://unpkg.com/react@16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.development.js"></script>

The versions above are only meant for development, and are not suitable for production. Minified and optimized production versions of React are available at:

<script crossorigin src="https://unpkg.com/react@16/umd/react.production.min.js"></script>
<script crossorigin src="https://unpkg.com/react-dom@16/umd/react-dom.production.min.js"></script>

To load a specific version of react and react-dom, replace 16 with the version number.

Why the crossorigin Attribute?

If you serve React from a CDN, we recommend to keep the crossorigin attribute set:

<script crossorigin src="..."></script>

We also recommend to verify that the CDN you are using sets the Access-Control-Allow-Origin: * HTTP header:

This enables a better error handling experience in React 16 and later.

Please visit mobiosolutions.com for React.js project development.

Leave a Reply

Your email address will not be published. Required fields are marked *