You don’t need webpack / Rollup / Babel / whatever to start with React

A common misconception about React is that you need to set up an entire toolchain to get started with it. While that might have been true in the past, that certainly isn’t the case today.

From the React Docs:

The majority of websites aren’t, and don’t need to be, single-page apps. With a few lines of code and no build tooling, try React in a small part of your website. You can then either gradually expand its presence, or keep it contained to a few dynamic widgets.

Basically you need to do three things:

  1. Load React by including a prebuilt version
  2. Create a target container
  3. Render your app inside the container

Like so:

<!-- 1. Load React -->
<script src="" crossorigin></script>
<script src="" crossorigin></script>

<!-- 2. Create a target container -->
<div id="root"></div>

<!-- 3. Render your app inside the container -->
        <p>Hello from React {React.version}!</p>,

💡 This approach also works fine for legacy projects where you want to sneak in some React 🙂

This way you can jump right in and get started with it. It’s only later – for example when you start shipping into production and have no control over the browsers being used – that you might need Babel and the lot. You can of course always use create-react-app which takes away the hassle of setting up your React Dev Environment.

👨‍🏫 This topic is also covered in my workshop React from Scratch. If you’re new to React I’d heartedly recommend it 😉

Did this help you out? Like what you see?
Thank me with a coffee.

I don\'t do this for profit but a small one-time donation would surely put a smile on my face. Thanks!

BuymeaCoffee (€3)

To stay in the loop you can follow @bramus or follow @bramusblog on Twitter.

Published by Bramus!

Bramus is a frontend web developer from Belgium, working as a Chrome Developer Relations Engineer at Google. From the moment he discovered view-source at the age of 14 (way back in 1997), he fell in love with the web and has been tinkering with it ever since (more …)

Unless noted otherwise, the contents of this post are licensed under the Creative Commons Attribution 4.0 License and code samples are licensed under the MIT License

Leave a comment

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.