firebase-admin-node icon indicating copy to clipboard operation
firebase-admin-node copied to clipboard

[FR] Modular Import Support for Firebase Admin SDK

Open TrustyTechSG opened this issue 1 year ago • 3 comments

Is your feature request related to a problem? Please describe. The current Firebase Admin JS SDK does not support modular imports similar to the frontend Firebase SDK. For example, in the frontend SDK, I can use modular imports like:

import { doc, getDoc } from "firebase/firestore";

Describe the solution you'd like I would like the Firebase Admin SDK to support modular imports similar to the frontend SDK. For example:

import { doc, getDoc } from "firebase-admin/firestore";

This would align the Admin SDK with the frontend SDK’s modular API and provide a more consistent developer experience.

Describe alternatives you've considered Creating a custom wrapper around the Admin SDK to mimic modular imports. However, this adds unnecessary complexity and maintenance overhead.

Additional context We'd like to share code between server and frontend.

TrustyTechSG avatar Nov 21 '24 23:11 TrustyTechSG

I found a few problems with this issue:

  • I couldn't figure out how to label this issue, so I've labeled it for a human to triage. Hang tight.
  • This issue does not seem to follow the issue template. Make sure you provide all the required information.

google-oss-bot avatar Nov 21 '24 23:11 google-oss-bot

Yes I'd love to see this as well. When bundling firebase-admin in Lambdas, it's 9 MB without modification. Way to much

aaarichter avatar Jan 06 '25 12:01 aaarichter

I'd like this to get implemented as well. Modular API is so good.

I got confused with such differences and wrote a cloud function entirely based on the client SDK instead the admin SDK, so now I might have to rewrite basically all the queries and most of the logic. This is so frustrating.

Furthermore, we based our whole logic to use doc, getDoc and getDocFromCache to prevent reading several times the same data in the middlewares we created (and, I guess, spend more). For what I was able to see, firebase-admin/firestore doesn't have anything like getDocFromCache.

~I might be wrong, as we didn't yet brought online such project but run only via the emulator, but I think the only difference between creating a Node.JS application with the front-end client and using Admin SDK is the permissions you get access to (might not need them) and perhaps the path of requests.~

~By using firestore as an example, I can think of the retrieval of an http call to the project (firebase/app) vs a direct internal call (firebase-admin).~

EDIT:

I was right. Once brought this online, we tested it on an environment with firestore rules and the application was said to not have enough permissions, so we had to convert it in order to let it have privileges.

alexandercerutti avatar Jun 10 '25 17:06 alexandercerutti