Hackforge Academy

Category: react

what is package.json in react

Published on 26 Mar 2026

Explanation

package.json is the main configuration file of a React app πŸ“¦. It stores project information like name, version, and whether the project is private. It acts as the central control file for managing the app setup.

Code:

{
 "name": "my-react-app",
 "version": "1.0.0",
 "private": true 
}

Explanation

The dependencies section lists all libraries required for the React app to run βš›οΈ. When you run npm install, these packages are automatically downloaded.

Code:

{ "dependencies": { "react": "^18.2.0",
 "react-dom": "^18.2.0" } 
}

Explanation

The scripts section defines reusable commands like starting or building the app πŸš€. You can run them using npm start or npm run build.

Code:

{ "scripts": { 
"start": "react-scripts start", 
"build": "react-scripts build" 
}
 }

Explanation

The version field represents the current version of the project πŸ”’. It helps track updates and releases during development.

Code:

{ "version": "1.0.0" }

Explanation

The name field specifies the project name 🏷️. It is useful when publishing the project as a package or identifying it in development.

Code:

{ "name": "my-react-app" }

Explanation

The private field prevents accidental publishing of the project to npm πŸ”’. It is usually set to true for React applications.

Code:

{ "private": true }

Explanation

The devDependencies section stores packages needed only during development πŸ› οΈ, such as testing tools or linters.

Code:

{ "devDependencies": { "eslint": "^8.0.0" } }

Explanation

The browserslist section defines which browsers your React app should support 🌐. This helps optimize compatibility and performance.

Code:

{ "browserslist": { 
"production": [">0.2%", "not dead"], 
"development": ["last 1 chrome version"] 
} 
}

πŸš€ Learn Spring Boot with real-world projects

πŸ’‘ Build REST APIs step by step

🧠 Improve backend development skills

🎯 Get career-ready practical training

Join Our Free WhatsApp Community

Direct access to niche-specific mentors and peers on WhatsApp.

🐍

Python Community

Discuss Django, FastAPI, AI integration, and automation scripts with 15k+ developers.

Join Python Community
βš›οΈ

React Community

Master Next.js, Framer Motion, and State Management. Share your latest UI components.

Join React Community
β˜•

Java Community

Deep dives into Spring Boot, Microservices architecture, and high-performance backend ops.

Join Java Community