Creating React app without create-react-app
In this Blog we will learn to create react app with create-react-app
Faisal Husain
Let's build our react app from scratch we'll not use npm create-react-app, but instead, we'll build our app from scratch and see what happens behind when we enter npm create-react-app.
So let's start by making a new directory
In this we will initialize package.json
Next, we will install React and React-DOM packages using npm.
We will set up the folder structure as same as we get from create-react-app our src will contain index.js (which you can also name as App.js or whatever you like).
- make a new folder src
- In src make a new file index.js
- In the source folder ie your main folder create index.html
Now the most important part!! PARCEL (BUNDLERS)
We need a bundler for our react-app to work. Bundlers are used in both development and production. There are many bundlers out there like vite , parcel, webpack For our app we are going to use PARCEL for our app Bundlers do many things behind the scene
- Hot module reload -keeps track of every changes in the app.
- Image optimization
- Caching and many more functionality are offered by Parcel
NOW WE KNOW WHAT ARE BUNDLER LETS INSTALL PARCEL INTO OUR APP.
Till now you folder structure should look like this-
NOW put this code in you index.html file-
And put this code in src>index.js file-
Now run this command to run your app locally-
Congratulations you have successfully made a react app from scratch.
Thank You