Socket
Socket
Sign inDemoInstall

firebase-admin

Package Overview
Dependencies
193
Maintainers
4
Versions
130
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    firebase-admin

Firebase admin SDK for Node.js


Version published
Weekly downloads
1.6M
increased by8.14%
Maintainers
4
Install size
44.3 MB
Created
Weekly downloads
 

Package description

What is firebase-admin?

The firebase-admin npm package is a server-side library that allows Node.js applications to interact with Firebase services such as Firestore, Firebase Realtime Database, Firebase Authentication, and Firebase Cloud Messaging. It provides administrative privileges to perform operations like creating and managing users, setting security rules, and accessing database services programmatically.

What are firebase-admin's main functionalities?

Authentication

This feature allows you to create and manage users in Firebase Authentication. The code sample demonstrates how to create a new user with specific attributes.

admin.auth().createUser({
  email: 'user@example.com',
  emailVerified: false,
  password: 'secretPassword',
  displayName: 'John Doe',
  photoURL: 'http://www.example.com/12345678/photo.png',
  disabled: false
})
.then(function(userRecord) {
  console.log('Successfully created new user:', userRecord.uid);
})
.catch(function(error) {
  console.log('Error creating new user:', error);
});

Database

This feature enables you to interact with Firestore, a NoSQL database. The code sample shows how to add a new document to a collection in Firestore.

var db = admin.firestore();
var docRef = db.collection('users').doc('alovelace');

var setAda = docRef.set({
  first: 'Ada',
  last: 'Lovelace',
  born: 1815
});

Realtime Database

This feature allows you to interact with Firebase Realtime Database. The code sample demonstrates how to set data in the database.

var db = admin.database();
var ref = db.ref('server/saving-data/fireblog');
var usersRef = ref.child('users');
usersRef.set({
  alanisawesome: {
    date_of_birth: 'June 23, 1912',
    full_name: 'Alan Turing'
  },
  gracehop: {
    date_of_birth: 'December 9, 1906',
    full_name: 'Grace Hopper'
  }
});

Cloud Messaging

This feature is used to send notifications and messages to users through Firebase Cloud Messaging. The code sample illustrates how to send a message to a device with a specific registration token.

var registrationToken = 'YOUR_REGISTRATION_TOKEN';

var message = {
  data: {
    score: '850',
    time: '2:45'
  },
  token: registrationToken
};

admin.messaging().send(message)
  .then((response) => {
    console.log('Successfully sent message:', response);
  })
  .catch((error) => {
    console.log('Error sending message:', error);
  });

Other packages similar to firebase-admin

Readme

Source

Build Status

Firebase Admin Node.js SDK

Table of Contents

Overview

Firebase provides the tools and infrastructure you need to develop your app, grow your user base, and earn money. The Firebase Admin Node.js SDK enables access to Firebase services from privileged environments (such as servers or cloud) in Node.js.

For more information, visit the Firebase Admin SDK setup guide.

Installation

The Firebase Admin Node.js SDK is available on npm as firebase-admin:

$ npm install --save firebase-admin

To use the module in your application, require it from any JavaScript file:

const { initializeApp } = require("firebase-admin/app");

initializeApp();

If you are using ES2015, you can import the module instead:

import { initializeApp } from "firebase-admin/app";

initializeApp();

Contributing

Please refer to the CONTRIBUTING page for more information about how you can contribute to this project. We welcome bug reports, feature requests, code review feedback, and also pull requests.

Supported Environments

We support Node.js 14 and higher.

Please also note that the Admin SDK should only be used in server-side/back-end environments controlled by the app developer. This includes most server and serverless platforms (both on-premise and in the cloud). It is not recommended to use the Admin SDK in client-side environments.

Documentation

Acknowledgments

Thanks to the team at Casetext for transferring ownership of the firebase-admin npm module over to the Firebase team and for their longtime use and support of the Firebase platform.

License

Firebase Admin Node.js SDK is licensed under the Apache License, version 2.0.

Your use of Firebase is governed by the Terms of Service for Firebase Services.

Keywords

FAQs

Last updated on 16 Jun 2022

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc