The HTTPS Callable functions Web Quickstart demonstrates how to send requests to a server-side function and get a response back using the Firebase JS SDK. It interoperates with the iOS and Android database quickstarts.
Read more about Cloud Functions for Firebase
- Create your project in the Firebase Console.
- Enable the Google sign-in provider in the Authentication > SIGN-IN METHOD tab.
- You must have the Firebase CLI installed. If you don't have it, install it with
npm install -g firebase-tools
and then configure it withfirebase login
. - Clone this repository and open the functions directory:
git clone https://github.com/firebase/quickstart-js; cd quickstart-js/functions
- Install cloud functions dependencies:
npm --prefix functions install
- On the command line run
firebase use --add
and select the Firebase project you have created. - On the command line run
firebase deploy
to deploy the application. - On the command line run
firebase open hosting:site
to open the deployed web app. - Sign in the Application using the Button.
- Write two numbers in the boxes and Click the "Add the Two Numbers" button.
- You should be getting the result of the addition.
- Write a message in the Box below and Click the "Add Message" button.
- The message is added below but if it contains bad words or SHOUTING!! it will be sanitized.
To run the sample app locally during development:
- Run
npm install
to install dependencies. - Run
npm --prefix functions run build
to build the functions using Vite. - Run
firebase emulators:start
to start the local Firebase emulators. - Run
npm run dev
to serve the app locally using Vite This will start a server locally that servesindex.html
onhttp://localhost:5173/index.html
.
Running the app using the Firebase CLI:
- Run
npm install
to install dependencies. - Run
npm run build
to build the app using Vite. - Run
firebase emulators:start
to start the local Firebase emulators. - In your terminal output, you will see the "Hosting" URL. By default, it will be
127.0.0.1:5002
, though it may be different for you. - Navigate in your browser to the URL output by the
firebase emulators:start
command.
© Google, 2018. Licensed under an Apache-2 license.