Troubleshooting: React App Shows Blank White Page on Cloudflare Pages

If you’ve recently exported a React project from Google AI Studio or a similar tool and deployed it to Cloudflare Pages, you might have encountered a frustrating issue: the deployment is successful, but when you visit the site, you’re greeted with a completely blank white page.

This is a common issue often caused by a missing entry point in your index.html.

The Problem

When you inspect the source of your index.html (often located in the public folder or at the root), you might see something like this:

<body>
    <div id="root"></div>
</body>

Notice the lack of a script connecting your HTML to your React code? Without pointing to your main JavaScript file (usually index.tsx or main.tsx), the browser renders the empty #root div and nothing else happens.

The Solution

To fix this, you need to explicitly link your main entry file in the body of your index.html.

Add the following line inside the <body> tag, usually right after the root div:

<script type="module" src="/index.tsx"></script>

Your corrected index.html should look like this:

<body>
    <div id="root"></div>
    <script type="module" src="/index.tsx"></script>
</body>

(Note: If your entry file is named main.tsx or index.jsx, update the src attribute accordingly.)

Why this happens

Some code generation tools or templates might omit this link, assuming a specific build setup that auto-injects it, or simply due to a generation error. Cloudflare Pages (and Vite/others) need this entry point to kickstart the React application.

Once you add this line, commit your changes and push to your repository. Cloudflare Pages should rebuild quite quickly, and your site should load correctly!