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-toolsand 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 --addand select the Firebase project you have created. - On the command line run
firebase deployto deploy the application. - On the command line run
firebase open hosting:siteto 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 installto install dependencies. - Run
npm --prefix functions run buildto build the functions using Vite. - Run
firebase emulators:startto start the local Firebase emulators. - Run
npm run devto serve the app locally using Vite This will start a server locally that servesindex.htmlonhttp://localhost:5173/index.html.
Running the app using the Firebase CLI:
- Run
npm installto install dependencies. - Run
npm run buildto build the app using Vite. - Run
firebase emulators:startto 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:startcommand.
© Google, 2018. Licensed under an Apache-2 license.