Created
March 17, 2022 20:56
-
-
Save ivanfgm/ef582dc92a30cc896aeb52645bacd3ff to your computer and use it in GitHub Desktop.
Use Firebase Admin SDK inside a Next.js project.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// I usually put this in config/firebaseAdmin.js | |
import * as admin from 'firebase-admin' | |
// You need your account service key json file inlined in .env | |
let serviceAccount = JSON.parse(process.env.FIREBASE_ACCOUNTKEY) | |
let config = { | |
credential: admin.credential.cert(serviceAccount) | |
} | |
export default !admin.apps.length ? admin.initializeApp(config) : admin; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment