Since Deno has been released stable build just a few days ago, Is there a possible way to use firebase-admin with Deno?
-
1check this repo, no guarantee that its working since its 10 months old: https://github.com/denoserverless/firebase-auth-rest, it might just give you idea how to start. – ROOT May 17 '20 at 14:34
-
3This question should be directed to the Firebase community. – Evandro Pomatti May 17 '20 at 14:49
-
https://deno.land/x/firestore_store@v2.0.2-rerelease Try this. – Hiral Jan 08 '21 at 07:16
3 Answers
At the time of this post, both Google documentation and Firebase repositories have no Deno support.
https://firebase.google.com/docs/admin/setup
https://github.com/firebase?q=firebase-admin
Maybe they are already working on it, I can't know. You can reach out to them and do a feature request and ask how you can help.

- 13,341
- 16
- 97
- 165
As @Evandro Pomatti pointed out, there is no official support from the firebase team as a native Deno module. However, NPM modules can be used within a Deno codebase, so why not just use the existing firebase-admin
codebase?
see How to use npm module in DENO?
import { createRequire } from 'https://deno.land/std/node/module.ts';
const require = createRequire(import.meta.url);
const admin = require('firebase-admin');
const text = await Deno.readTextFile('path/to/serviceAccountKey.json');
const adminKey = JSON.parse(text);
admin.initializeApp({
credential: admin.credential.cert(adminKey),
databaseURL: 'https://databaseName.firebaseio.com'
});
const db = admin.database();
const ref = db.ref('restricted_access/secret_document');
ref.once('value', function(snapshot) {
console.log(snapshot.val());
});
Since Deno is a secure runtime by default, reading files require explicit permissions using the --allow-read
command
deno run --allow-read=node_modules myfile.ts

- 10,606
- 5
- 40
- 57
-
-
I tried doing something similar using Deno, unfortunately it errors with a crypto error. See https://github.com/ben-xD/push/pull/22/commits/4085b55f694ec47ee72f4ec80afba96d873d43fd. Switched to Node in that MR. – Ben Butterworth Jul 28 '23 at 03:00
Looks like Firebase is supported via few polyfills. https://deno.com/deploy/docs/tutorial-firebase
But you might hit a roadblock. Let me if that works for you.

- 472
- 4
- 10
-
That’s firebase 8x, but they’re now on 9x and it has better ES module support. Might be a better choice and might “just work”. – SeanMC May 10 '23 at 13:28