Accessing Firebase Database via Fetch

I just found this topic: Can I use firebase database (not realtime database) inside cloudflare worker?

I am trying to access a Firestore via Fetch but I am not succeeding.

I started a simple project with a worker.js and a wrangler.toml.

This is my firebase.js:

const { initializeApp } = require('firebase-admin/app')
const { getFirestore } = require('firebase-admin/firestore')

const firebaseConfig = {
  apiKey: process.env.FIREBASE_API_KEY,
  authDomain: process.env.FIREBASE_AUTH_DOMAIN,
  projectId: process.env.FIREBASE_PROJECT_ID,
  storageBucket: process.env.FIREBASE_STORAGE_BUCKET,
  messagingSenderId: process.env.FIREBASE_MESSAGING_SENDER_ID,
  appId: process.env.FIREBASE_APP_ID,
  measurementId: process.env.FIREBASE_MEASUREMENTID

const app = initializeApp(firebaseConfig)

const db = getFirestore(app)

export { db }

This is the worker.js

import { db } from './firebase'

export default {
  async fetch(request, env, ctx) {
    const snapshot = await db.collection('users').get()
    snapshot.forEach((doc) => {
      console.log(, '=>',

    return new Response('Test')

When running wrangler dev I get several errors in the terminal, which demonstrate (I believe) an error in my implementation.

Does anyone know what I’m missing?