firebase.json Builder

Generate a Firebase Hosting config with rewrites and cache headers

Build a valid firebase.json for Firebase Hosting with a public directory, SPA rewrites, immutable cache headers for hashed assets, clean URLs, trailing-slash control, and ignore patterns — copy or download instantly.

What does the public directory in firebase.json do?

The public key tells Firebase Hosting which folder contains the static files to deploy. For most modern build tools this is dist or build. Everything inside it is uploaded and served from your hosting site.

A correct firebase.json without the guesswork

Firebase Hosting is configured by a single firebase.json file, and small mistakes — a wrong public directory, a missing SPA rewrite, or no cache headers — lead to 404s on deep links or stale assets after deploys. This builder assembles a valid config from a few toggles so your first firebase deploy works.

How it works

The tool writes a hosting object. The public key points at your build folder, and ignore excludes firebase.json and dotfiles (plus node_modules if you want). When the single-page-app option is on, it adds a catch-all rewrite that maps ** to /index.html, so client-side routes resolve instead of 404ing. The cache-header block applies Cache-Control: public, max-age=<seconds>, immutable to hashed static assets (js, css, fonts, images) while forcing no-cache on index.html, which is the standard pattern for content-hashed builds. cleanUrls and trailingSlash map directly to Firebase’s own options.

Example and notes

A typical Vite or Create React App setup uses dist (Vite) or build (CRA) as the public directory with the SPA rewrite enabled. Keep the asset max-age at 31536000 (one year) only when your bundler adds content hashes to filenames; without hashing, a long cache can serve stale code. The generated JSON is standard and can be extended later with redirects, headers for security, or multiple hosting targets.