DEV Community

Cover image for How to set up a React app using Parcel
3 2

How to set up a React app using Parcel

What is Parcel?

  • Parcel is a web app bundler that enables you to get up running with zero configuration

  • Unlike other bundlers like Webpack, Parcel doesnโ€™t require you to write a lot of code just to get started

  • It offers blazing fast performance because it utilizes multi core processing where others work off of complex and heavy transforms

Cool features ๐Ÿ˜Ž

  • ๐Ÿ“ Error logging => provides highlighted syntax in the code when it encounters an error
  • ๐Ÿ”ฅ Hot module replacement (HMR) => automatically updates modules as you make changes in develop
  • โœ‚๏ธ Code splitting => uses the import() syntax to split up your bundle
  • ๐Ÿ’ป Automatic transforms => code is automatically transformed using Babel, PostCSS, and PostHTML

๐Ÿ”ฅ And many more!

Alright, letโ€™s get started! ๐Ÿ

Homer Simpson saying yay

Create a new NPM (or with your preferred package manager) app

mkdir my-awesome-app
cd my-awesome-app
npm init

๐Ÿ”ฅ npm init will ask you a bunch of questions, if donโ€™t want to answer them, tack on the -y at the end: npm init -y

Letโ€™s install the dependencies ๐Ÿ“ฆ

  • React
  • Babel
  • Parcel
npm install --save react
npm install --save react-dom
npm install --save-dev @babel/preset-react
npm install --save-dev @babel/preset-env
npm install --save-dev parcel-bundler

Create a .babelrc file

{
 "presets": ["@babel/preset-react"]
}

Create a index.html file

<!DOCTYPE html>
<html>
    <head>
        <title>๐Ÿ•</title>
    </head>
    <body>
        <div id="app"></div>
        <script src="index.js"></script>
    </body>
</html>

Create a index.js file

import React from "react";
import ReactDOM from "react-dom";

function App () {
 return <h1>This is my amazing app</h1>
}

const mount = document.getElementById("app");
ReactDOM.render(<App />, mount);

Add the entry point to our package.json

"scripts": {
  "start": "parcel index.html",
},
npm start

Weโ€™re done! We can view our app on http://localhost:1234

done

Now go out and build that todo app!

just kidding

cover image from: https://www.woolha.com/media/2018/09/using-parceljs-bundler-for-building-reactjs-application-1200x627.jpg

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

Top comments (0)

nextjs tutorial video

Youtube Tutorial Series ๐Ÿ“บ

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series ๐Ÿ‘€

Watch the Youtube series

๐Ÿ‘‹ Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someoneโ€™s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay