DEV Community

govindbisen
govindbisen

Posted on

react setup without vite or create react app,(2)

๐Ÿš€ Create React App Manually (Without CRA or Vite)

Hey developers ๐Ÿ‘‹,
In this post, Iโ€™ll show you how to create a React app manually from scratch without using create-react-app or Vite. This will help you understand the building blocks of React projects โ€” what happens under the hood.

๐Ÿ‘‰ Full code is available on my GitHub: manualreact


1. Create a folder and initialize the project

mkdir manualreact
cd manualreact
npm init -y
Enter fullscreen mode Exit fullscreen mode

The -y flag accepts all defaults, so it quickly generates a package.json.


2. Install React and ReactDOM

npm install react react-dom
Enter fullscreen mode Exit fullscreen mode
  • react โ†’ Core library for writing components, managing state, and using hooks.
  • react-dom โ†’ Used to render React components into the actual DOM (browser).

Example:

import React from "react";
import ReactDOM from "react-dom/client";
import App from "./App";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(<App />);
Enter fullscreen mode Exit fullscreen mode

3. But waitโ€ฆ browsers donโ€™t understand JSX directly โš ๏ธ

Up to this point, we have written React code.
But browsers only understand plain JavaScript, HTML, and CSS.
So we need tools that bundle and transpile our code:


๐Ÿ”น Webpack (Bundler)

  • Takes all your files (.js, .css, .jpg, etc.)
  • Combines them into a single optimized bundle (bundle.js)
  • Browser can then load it efficiently.

๐Ÿ”น Babel (Transpiler)

  • Converts modern ES6+ and JSX code into older JavaScript that browsers understand.

Examples:

JSX โž React.createElement

// ES6/JSX
const element = <h1>Hello React</h1>;
Enter fullscreen mode Exit fullscreen mode

Babel output:

const element = React.createElement("h1", null, "Hello React");
Enter fullscreen mode Exit fullscreen mode

Arrow function โž ES5 function

// ES6
const sum = (a, b) => a + b;
Enter fullscreen mode Exit fullscreen mode

Babel output:

var sum = function(a, b) {
  return a + b;
};
Enter fullscreen mode Exit fullscreen mode

4. File Structure and Configurations

Iโ€™ve set up all necessary files (index.html, webpack.config.js, babel.config.js, entry point, etc.) in my repo.
๐Ÿ‘‰ You can check it out here: manualreact on GitHub


โœ… Conclusion

By setting up React manually:

  • You understand how bundlers and transpilers work.
  • You gain full control over project configuration.
  • Itโ€™s a great way to learn the internals behind create-react-app and Vite.

๐Ÿ’ก Pro tip: Once youโ€™re comfortable with this, you can explore advanced Webpack loaders, plugins, and optimizations.


๐Ÿ‘‰ Check the complete project on GitHub, BUT do not download, write the code, install dependencies one by one, make each file one by one.


Top comments (0)