Check out the codelab: Click Here
A minimal web demo using Vite and the Firebase JS SDK to call Firebase AI getGenerativeModel and summarize text.
- Node.js 18+
- Firebase project (for Hosting) and the Web app config values
- Firebase CLI (
npm i -g firebase-tools) if you plan to deploy
npm installUpdate src/app.js with your Firebase web app config:
const firebaseConfig = {
apiKey: "<YOUR_API_KEY>",
authDomain: "<YOUR_PROJECT>.firebaseapp.com",
projectId: "<YOUR_PROJECT>",
storageBucket: "<YOUR_PROJECT>.firebasestorage.app",
messagingSenderId: "<SENDER_ID>",
appId: "<APP_ID>",
measurementId: "<MEASUREMENT_ID>"
};Runs the Vite dev server at http://localhost:5173 by default.
npm run devOutputs production assets to dist/ (configured via vite.config.js).
npm run buildnpm run preview- Initialize (first time only):
firebase login
firebase init hosting
# choose: Use an existing project or create new
# public directory: dist
# configure as single-page app: y- Build and deploy:
npm run deploy(or npm run build && firebase deploy --only hosting)
/ (root)
├─ src/
│ ├─ index.html
│ ├─ app.js
│ └─ styles.css
├─ vite.config.js
├─ package.json
└─ README.md
- The example uses model
gemini-2.5-flashwith a simple system instruction. - Ensure billing/API access is enabled as required for Firebase AI features.