Menu

How we prerendered a Vite + React SPA on Firebase Hosting for SEO (without migrating to Next.js)
📰

How we prerendered a Vite + React SPA on Firebase Hosting for SEO (without migrating to Next.js)

DEV Community: vite·Muhammad Samee Baig·3 days ago
#8pO0wxwj
#devtovite#devto#dev#root#html
Long article (2086 words) — no AI summary yet.
Reading 0:00
15s threshold

We build OnScene , a live shopping app for Pakistan. Its marketing site, blog and policy pages are a Vite + React single-page app hosted on Firebase Hosting. For a long time every URL on it returned the same empty index.html . This post is about how we fixed that without migrating to Next.js: a build-time prerender step, a few build gates, and some Firebase Hosting configuration. It also covers the two bundling mistakes that bit us along the way.

The problem: one shell for every URL

A client-rendered SPA serves one HTML file for every route. That file has one <title> , one description, no <h1> and no body text. Googlebot renders JavaScript eventually, but plenty of consumers do not: Bing's indexing was inconsistent for us, most AI crawlers fetch raw HTML, and WhatsApp, X and LinkedIn link previews never run your JS. For all of them, our 30-odd public pages looked like one page repeated.

The usual answer is "move to Next.js or Astro".…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.