Cloud Functions



After using test data in Algolia to make sure results were retuning properly I set up Cloud Functions to trigger when items are added, updated or deleted to the Firestore collection.

Setup Steps

  • Firebase init Functions
  • NPM install algoliasearch
  • firebase functions:config:set algolia.appid"" algolia.apikey""
  • firebase deploy --only functions

This video walks through an example, however some of the syntax has changed since the video was created. Here is the main TS file for my project on Github The trickiest part of getting the functions to work was spacing, if the spacing was not perfect the function fails to upload. After getting one function to run it was easiest to copy and paste instead of trying to retype the next function.

Another tip - If you are adding/updating functions you can deploy specific functions, by default "firebase deploy --only functions" deploys all functions even if they have not changed.