Skip to main content

Cloud Functions for Firebase

What does it do?#

Cloud Functions for Firebase let you automatically run backend code in response to events triggered by Firebase features and HTTPS requests. Your code is stored in Google's cloud and runs in a managed environment. There's no need to manage and scale your own servers.

Installation#

Before installing the Cloud Functions for Firebase plugin, ensure that you have followed the Getting Started documentation and have initialized FlutterFire.

1. Add dependency#

Add the cloud_functions dependency to your projects pubspec.yaml file:

pubspec.yaml
dependencies:
flutter:
sdk: flutter
firebase_core: "^0.7.0"
cloud_functions: "^0.9.0"

2. Download dependency#

Download the dependency by running the following command in your project:

$ flutter pub get

3. (Web Only) Add the SDK#

If using FlutterFire on the web, add the firebase-functions JavaScript SDK to your index.html file:

web/index.html
<html>
...
<body>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-app.js"></script>
<script src="https://www.gstatic.com/firebasejs/8.6.1/firebase-functions.js"></script>
</body>
</html>

4. Rebuild your app#

Once complete, rebuild your Flutter application:

$ flutter run

Next Steps#

Once installed, you're ready to start using Cloud Functions for Firebase in your Flutter Project. View the Usage documentation to get started.