Package selection guidance compiled from public package information, community data, and project usage.
Firebase Admin SDK for Dart, implemented as a wrapper around the official Node.js SDK. It enables server-side Firebase operations in Dart environments by leveraging native Node.js functionality through interop. This package is ideal for backend services, cloud functions, and server applications that require administrative access to Firebase resources such as authentication, Firestore, and messaging. It provides a familiar API for developers already experienced with Firebase Admin on Node.js.
Use cases
Server-side Firebase administration
Cloud functions with Dart
Backend services integration
Authentication management
Firestore data manipulation
Key features
Node.js SDK wrapper
Admin-level Firebase access
Dart-compatible interface
Seamless integration with existing Firebase workflows
Supports multiple Firebase services
Suitable for
Backend developers using Dart
Server applications requiring Firebase admin access
Cloud function environments
Projects needing Firebase authentication control
Teams familiar with Firebase Admin on Node.js
Considerations
Requires Node.js runtime environment
Limited to server-side use cases
Not suitable for Flutter mobile apps
Depends on external Node.js process
May have platform-specific setup requirements
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
Write server-side Firebase applications in Dart using Node.js as a runtime.
Firestore Timestamps migration:
Firestore deprecated usage of DateTime objects in favor of custom Timestamp type and recommends
migrating as soon as possible.
By default all timestamps are still returned as DateTime objects and you can access them with
DocumentData.getDateTime or DocumentData.setDateTime.
To start using Timestamps you must configure Firestore as follows:
final app = FirebaseAdmin.instance.initializeApp();
final firestore = app.firestore();
// Call Firestore.settings at the very beginning before any other calls:
firestore.settings(FirestoreSettings(timestampsInSnapshots: true));
// You can read and write data now, but make sure to use new `setTimestamp` and `getTimestamp`// methods of `DocumentData`.
Installation
Add this package as a dependency to your pubspec.yaml:
Below is a simple example of using Realtime Database client:
import'dart:async';
import'package:firebase_admin_interop/firebase_admin_interop.dart';
Future<void> main() async {
final serviceAccountKeyFilename = '/absolute/path/to/service-account.json';
final admin = FirebaseAdmin.instance;
final cert = admin.certFromPath(serviceAccountKeyFilename);
final app = admin.initializeApp(newAppOptions(
credential: cert,
databaseURL: "YOUR_DB_URL",
));
final ref = app.database().ref('/test-path');
// Write value to the database at "/test-path" location.await ref.setValue("Hello world");
// Read value from the same database location.var snapshot = await ref.once("value");
print(snapshot.val()); // prints "Hello world".
}
Note that it is only possible to use JSON-compatible values when reading
and writing data to the Realtime Database. This includes all primitive
types (int, double, bool), string values (String) as well as
any List or Map instance.
For Firestore there are a few more supported data types, like DateTime
and GeoPoint.
Building
This library depends on node_interop package which provides Node.js
bindings and build_node_compilers package which allows compiling
Dart applications as Node.js modules.
To enable builders provided by build_node_compilers first add following
dev dependencies to your pubspec.yaml:
Next, create build.yaml file with following contents:
targets:$default:sources:-"lib/**"-"node/**"# Assuming your main Dart files is in node/ folder (recommended).-"test/**"builders:build_node_compilers|entrypoint:options:compiler:dart2js# To compile with dart2js by default
You can now build your project using build_runner:
# By default compiles with DDC
pub run build_runner build --output=build
# To compile with dart2js:
pub run build_runner build \
--define="build_node_compilers|entrypoint=compiler=dart2js" \
--define="build_node_compilers|entrypoint=dart2js_args=[\"--minify\"]" \ # optional, minifies resulting code
--output=build/
Status
This library is considered stable though not feature complete. It is recommended to check
dev versions for latest updates and bug fixes.
Make sure to checkout CHANGELOG.md
after every release, all notable changes and upgrade instructions will
be described there.
Current implementation coverage report:
[x] admin
[x] admin.auth
[x] admin.app
[x] admin.credential
[x] admin.database
[x] admin.firestore
[x] admin.messaging
[ ] admin.storage
Features and bugs
Please file feature requests and bugs at the issue tracker.