Course contentsShow
← React
Lesson 40 of 2,3962. Setup and Modern ToolingFree lesson

The index.html Entry Point

Unlike CRA, Vite's index.html lives at the root and directly imports your app via a script tag.

The index.html Entry Point

You'll learn how Vite's index.html serves as the direct gateway to your React application, unlike Create React App's hidden approach.

Understanding Vite's Transparent Entry Point

In Create React App, the index.html file lived buried inside a public folder, and you rarely thought about it—the tooling magically injected your JavaScript for you. Vite takes a different, more transparent approach: your index.html sits right at the project root, and you explicitly tell it to load your React app via a script tag.

Think of it like the front door to your house. With CRA, the door was hidden behind automation—you knew it existed but never really saw it. With Vite, the front door is right there in plain sight, and you can clearly see how visitors (the browser) enter your application.

What's Inside

Open your project's index.html and you'll see something like this:

<div id="root"></div>
<script type="module" src="/src/main.jsx"></script>

Two critical pieces:

  1. The root div: An empty container where your entire React component tree will render (remember component-based architecture?)
  2. The module script tag: Directly imports your main.jsx entry file—no magic bundling hiding this connection

The type="module" means modern JavaScript modules work natively in the browser during development. Vite uses this for lightning-fast hot module replacement.

Why This Matters

This transparency gives you control. Want to add a <link> to Google Fonts? Drop it right in this HTML. Need a meta tag for SEO? You know exactly where it goes. The entry point is explicit, not implicit.

Key Takeaway: Vite's index.html lives at the root and directly imports your app via <script type="module">, giving you transparent control over your application's entry point instead of hiding it behind tooling abstractions.