Setup Firebase Functions

Setting Up Firebase Functions

Working with functions is meant to be easy in FireSaaS. This guide will go over deploying the new user created function and working with / adding new functions.

Table of Contents


📣

I prepackaged one function in this project. It creates database entries for your users when they create an account. Let's go ahead and deploy that now.

Node Version

I recommend using NVM (opens in a new tab) or if you're on Windows NVM-for-Windows (opens in a new tab) if you don't already to manage your node versions.

Firebase Functions requires Node 18, so make sure you have Node 18 installed globally or install it via NVM and use it.

nvm install 18
nvm use 18

Setup Firebase CLI

Make sure you have the Firebase CLI setup

npm install -g firebase-tools

This installs firebase globally on your machine.

Now we login

firebase login

Once you're logged in, cd into the functions directory

Then we can cd into functions and run yarn deploy, once this finishes your functions are live.

cd functions

You MUST run yarn first to install dependencies.

yarn

Then you can run deploy to deploy your functions to Firebase.

yarn deploy
📣

To deploy functions your Firebase account has to be on the Blaze account (Pay as you Go). Running deploy will prompt you to set this up if it isn't already.


Testing Functions Locally

You can run yarn serve inside the functions project to emulate functions locally. This is good for testing stuff out before you deploy.

yarn serve