1

I am unable to access firebase functions directly on the client side following the steps. I have configured exactly the same in my React Client app

import * as firebase from "firebase"
import 'firebase/firestore'
import 'firebase-functions'

require('dotenv').config()


var config = {
    apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
    storageBucket: process.env.REACT_APP_FIREBAES_STORAGE_BUCKET,
    databaseURL: process.env.REACT_APP_FIREBASE_DATABASE_URL,
    projectId: process.env.REACT_APP_FIREBASE_PROJECT_ID 
};

// Firebase is being initialized
let fb = firebase.initializeApp(config);
// Firestore is also working
let firestore = firebase.firestore()

// But when I tried to initiate functions it is failing
let functions = firebase.functions()
4
  • What is the error you are getting? Or is just nothing happening? Commented Mar 27, 2018 at 15:47
  • Are you on the very latest version of the Firebase SDK (4.12.0) -- this is a brand-new feature that was just released. Commented Mar 27, 2018 at 17:11
  • @ChaseDeAnda the error Uncaught TypeError: firebase.functions is not a function Commented Mar 27, 2018 at 17:32
  • @MichaelBleigh Yes, I am using (4.12.0) I have double checked it Commented Mar 27, 2018 at 17:33

1 Answer 1

4

You are importing the firebase-functions Node.js library, not the callable functions part of the SDK. Your imports should look like:

import * as firebase from "firebase/app"
import 'firebase/firestore'
import 'firebase/functions'
Sign up to request clarification or add additional context in comments.

2 Comments

Has this changed? I'm doing exactly this today and it's giving me the same "firebase.functions is not a function"
You need to add an at before, like: import '@firebase/firestore'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.