To get your React app started, there are a few essential commands.
create-react-app
npx create-react-app whatever-folder-name-you-want
This command is the big one. It will create a folder named whatever-folder-name-you-want
, initialize npm and a git repository in the folder, and create a starting file structure for your app.
It will also install the standard React libraries and dependencies you’ll need and set everything up for you.
Once you run that command, you’ll want to open the folder the command created with Visual Studio Code.
npm install
npm install name-of-the-package-to-install
The first command, create-react-app
installs the essential packages for a React app, but there are a lot of other packages out there that you may want to use in your particular app.
You can install any that you want using npm install
.
This will add the files for that package to the node_modules
folder, allowing you to use them in your app.
Some commonly used packages are:
Bootstrap
npm install bootstrap
React Router
npm install react-router-dom
React Bootstrap
npm install react-bootstrap
Redux
npm install redux
npm install react-redux
If there are other packages you’d like to include, you can find the documentation for that package and it will tell you the correct install command.
npm start
npm start
This command will start up your app with webpack’s development server (similar to something like Live Server for vanilla JavaScript) so you can see your app while you’re working on it.
You need to run this command in the top folder of your app (the folder create-react-app
created, for example, whatever-folder-name-you-want
)
Your app will be dynamically reloaded when you make changes and save them.
Thanks!