← Back to React Course | Chapter 1: Environment Setup & Tooling | Lesson 4 of 10

Create React App से App बनाना

Create React App एक machine है जो instantly आपको एक ready-to-use React project बना देती है, ताकि आपको सारे pieces हाथ से assemble न करने पड़ें।
Syntax
markup
npx create-react-app app-name
cd app-name
npm start

Create React App क्या Setup करता है

Create React App (CRA) एक command है जो एक ready-to-run React project generate करता है -- folder structure, एक build configuration, और एक dev server -- ताकि आपको एक bundler हाथ से configure न करना पड़े।

Note: CRA को globally install किए बिना एक brand-नया project scaffold करने के लिए npx create-react-app my-app run करें।
Warning: Create React App अब maintenance mode में है -- कई नए projects इसके faster dev server के लिए Vite (आगे cover किया गया) पसंद करते हैं।

उदाहरण: What Create React App Sets Up

bash
$ npx create-react-app my-app
Creating: my-app/src, my-app/public, my-app/package.json
Success! Your project is ready.

⚠️ Run this in your own terminal or Node.js environment.

Dev Server Start करना

एक CRA project के अंदर, npm start run करना एक local development server launch करता है (आमतौर पर localhost:3000 पर) जो आपके कोई file save करने पर automatically page reload करता है।

Note: काम करते समय npm start चलाने वाला terminal खुला रखें -- इसे बंद करना dev server रोक देता है।
Warning: एक CRA project में npm start एक production build से अलग है -- यह धीमा है और इसमें असली users के लिए न बना extra debugging help शामिल है।

उदाहरण: Starting the Dev Server

bash
$ npm start
Compiled successfully!
Local: http://localhost:3000

⚠️ Run this in your own terminal or Node.js environment.

CRA Folder Structure

एक fresh CRA project में आपके components के लिए एक src/ folder है (App.js और index.js से शुरू), static files जैसे HTML shell और favicon के लिए एक public/ folder, और dependencies list करने वाला package.json।

Note: index.js entry point है -- यह वह file है जो असल में ReactDOM.createRoot call करती है और आपके top-level App component को render करती है।
Warning: public/index.html के अंदर directly files edit करना page title या meta tags के लिए ठीक है, लेकिन component UI src/ में belong करती है, वहां नहीं।

उदाहरण: The CRA Folder Structure

bash
$ ls -R my-app
my-app:
node_modules  package.json  public  README.md  src

my-app/public:
favicon.ico  index.html  manifest.json  robots.txt

my-app/src:
App.css  App.js  App.test.js  index.css  index.js  logo.svg

⚠️ Run this in your own terminal or Node.js environment.

Related Topics
{# common_mistakes/chapter_summary/browser_support: on Hindi pages the view already swaps in the hi_ translation fields (or blanks these out if untranslated), so this renders correctly for both languages without a lang_code check here. #}
आम गलतियां
  1. नए projects के लिए Create React App उपयोग करना भले ही यह अब Vite के favor में actively recommend नहीं किया जाता।
  2. npm start और npm run build असल में क्या करते हैं यह न समझना।
  3. Generated config files को manually edit करना यह realize किए बिना कि वे updates पर reset हो सकती हैं।
चैप्टर सारांश
  • Create React App (CRA) एक command से एक पूरा React project scaffold करता है।
  • यह Webpack, Babel, और दूसरी tooling bundle करता है ताकि आपको उन्हें खुद configure न करना पड़े।
  • npm start एक local dev server run करता है; npm run build एक production bundle बनाता है।
  • CRA अब legacy माना जाता है -- Vite आज ज़्यादा commonly recommended alternative है।
ब्राउज़र सपोर्ट

Generated app खुद default रूप से सभी modern evergreen browsers को support करता है; CRA एक build tool है, कोई runtime concern नहीं।

Login to run this code

C/C++/Java/PHP execution requires a free account. Your code is saved — you'll land right back in the editor after logging in.