/bolt-ai-integration

Bolt.new AI and Firebase Cloud Messaging integration: Step-by-Step Guide 2025

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.

Matt Graham, CEO of Rapid Developers

Book a call with an Expert

Starting a new venture? Need to upgrade your web app? RapidDev builds application with your growth in mind.

Book a free No-Code consultation

How to integrate Bolt.new AI with Firebase Cloud Messaging?

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.

 

What You Actually Do

 

You create a server route or function (Node.js inside Bolt.new is common) that:

  • loads your Firebase service account credentials (private key, client email)
  • generates a Google OAuth 2.0 access token using those credentials
  • sends a JSON POST request to Firebase Cloud Messaging’s send endpoint
  • includes the target device’s FCM registration token and your message payload

This is 100% the same as integrating FCM with any Node backend — Bolt.new is just where you write and test the code.

 

What You Need From Firebase

 

Inside your Firebase project console, export a Service Account JSON file. It contains:

  • client\_email
  • private\_key
  • project\_id

Upload these into your Bolt.new project as environment variables, for example:

  • FIREBASE_CLIENT_EMAIL
  • FIREBASE_PRIVATE_KEY
  • FIREBASE_PROJECT_ID

FCM uses these to trust your backend when it sends notifications.

 

Fully Working Node.js Example (Safe for Bolt.new)

 

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;
}

 

Example Bolt.new Route That Calls FCM

 

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;

 

How You Use This Inside Bolt.new

 

  • Create backend folder structure (e.g., /server)
  • Add the above files
  • Set environment variables in the Bolt.new project settings
  • Call your route (POST /notify) with a valid device token to send a real push notification

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.

Want to explore opportunities to work with us?

Connect with our team to unlock the full potential of no-code solutions with a no-commitment consultation!

Book a Free Consultation

Client trust and success are our top priorities

When it comes to serving you, we sweat the little things. That’s why our work makes a big impact.

Rapid Dev was an exceptional project management organization and the best development collaborators I've had the pleasure of working with. They do complex work on extremely fast timelines and effectively manage the testing and pre-launch process to deliver the best possible product. I'm extremely impressed with their execution ability.

CPO, Praction - Arkady Sokolov

May 2, 2023

Working with Matt was comparable to having another co-founder on the team, but without the commitment or cost. He has a strategic mindset and willing to change the scope of the project in real time based on the needs of the client. A true strategic thought partner!

Co-Founder, Arc - Donald Muir

Dec 27, 2022

Rapid Dev are 10/10, excellent communicators - the best I've ever encountered in the tech dev space. They always go the extra mile, they genuinely care, they respond quickly, they're flexible, adaptable and their enthusiasm is amazing.

Co-CEO, Grantify - Mat Westergreen-Thorne

Oct 15, 2022

Rapid Dev is an excellent developer for no-code and low-code solutions.
We’ve had great success since launching the platform in November 2023. In a few months, we’ve gained over 1,000 new active users. We’ve also secured several dozen bookings on the platform and seen about 70% new user month-over-month growth since the launch.

Co-Founder, Church Real Estate Marketplace - Emmanuel Brown

May 1, 2024 

Matt’s dedication to executing our vision and his commitment to the project deadline were impressive. 
This was such a specific project, and Matt really delivered. We worked with a really fast turnaround, and he always delivered. The site was a perfect prop for us!

Production Manager, Media Production Company - Samantha Fekete

Sep 23, 2022