Preview:
const admin = require('firebase-admin');
const serviceAccount = require('../firebase-key.json'); // adjust path
require('dotenv').config(); // Make sure this line is included

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  databaseURL: process.env.FIREBASE_DB_URL // This must not be undefined
});

const db = admin.database();
const ref = db.ref('users');

module.exports = ref;
downloadDownload PNG downloadDownload JPEG downloadDownload SVG

Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!

Click to optimize width for Twitter