Learn how to integrate Bolt.new AI with Firebase Cloud Messaging in 2025 using this clear, step‑by‑step guide for fast, reliable app notifications.

Book a call with an Expert
Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.
To integrate Bolt.new with Firebase Cloud Messaging (FCM), you do not “connect Bolt to FCM.” Instead, you write backend code inside a Bolt.new workspace that calls FCM’s real HTTPS API using Firebase server credentials. Bolt.new is just your development environment; the integration happens through regular REST requests authenticated using a Firebase service account. Once you load your Firebase service account JSON into Bolt.new as environment variables, you can send push notifications to iOS/Android/Web clients directly through FCM’s v1 HTTP API.
You create a server route or function (Node.js inside Bolt.new is common) that:
This is 100% the same as integrating FCM with any Node backend — Bolt.new is just where you write and test the code.
Inside your Firebase project console, export a Service Account JSON file. It contains:
Upload these into your Bolt.new project as environment variables, for example:
FCM uses these to trust your backend when it sends notifications.
This example uses only real, official Google OAuth and FCM endpoints. No fake APIs. It will work inside Bolt.new exactly the same as on any Node server.
// fcm.js
// A minimal Firebase Cloud Messaging sender using service accounts
import fetch from "node-fetch";
import jwt from "jsonwebtoken";
const projectId = process.env.FIREBASE_PROJECT_ID;
const clientEmail = process.env.FIREBASE_CLIENT_EMAIL;
const privateKey = process.env.FIREBASE_PRIVATE_KEY.replace(/\\n/g, '\n');
// Step 1: Create a Google OAuth JWT for server-to-server auth
async function getAccessToken() {
const now = Math.floor(Date.now() / 1000);
const token = jwt.sign(
{
iss: clientEmail,
scope: "https://www.googleapis.com/auth/firebase.messaging",
aud: "https://oauth2.googleapis.com/token",
iat: now,
exp: now + 3600
},
privateKey,
{ algorithm: "RS256" }
);
const res = await fetch("https://oauth2.googleapis.com/token", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
assertion: token
})
});
const data = await res.json();
return data.access_token;
}
// Step 2: Send an FCM message
export async function sendPush(token, title, body) {
const accessToken = await getAccessToken();
const message = {
message: {
token: token, // device's FCM registration token
notification: { // what the user sees
title: title,
body: body
}
}
};
const url = `https://fcm.googleapis.com/v1/projects/${projectId}/messages:send`;
const res = await fetch(url, {
method: "POST",
headers: {
Authorization: `Bearer ${accessToken}`,
"Content-Type": "application/json"
},
body: JSON.stringify(message)
});
const data = await res.json();
return data;
}
You might expose an endpoint the AI agent or your frontend can call:
// routes/notify.js
import express from "express";
import { sendPush } from "../fcm.js";
const router = express.Router();
router.post("/", async (req, res) => {
const { deviceToken, title, body } = req.body;
try {
const result = await sendPush(deviceToken, title, body);
res.json({ ok: true, result });
} catch (err) {
res.status(500).json({ ok: false, error: err.message });
}
});
export default router;
Nothing about this is Bolt-specific; Bolt is simply where the code runs during development. The integration itself is entirely standard Firebase server API usage.
When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.