1. Home
  2. Analytics
  3. Firebase
  4. Firebase – Sync data with your Construct 2 game
  1. Home
  2. Game Developing
  3. Construct 2
  4. Tutorials
  5. Firebase – Sync data with your Construct 2 game

Firebase – Sync data with your Construct 2 game


Get Started

If you want to use Firebase, please create a new account or login to your existing one.

  Firebase - Console
Just to let you know...

Firebase offers a free plan which is allowing you to use 2 projects. If you need more, you have to upgrade to a paid plan.

Create a project

First of all you need to create a new project (alternatively you can login to AdMob and export your existing app to Firebase)

Click on Create new Project and fill out all needed information.


Then confirm the dialog.

Now you are able to add Apps to your project by clicking the “Add App” button (upper right corner).

firebase_new_appThen select the platform of your app.


Fill out all needed information for your choosen platform and fill out all needed information.


Here you can add and configure login handlers for instance

  • Facebook Login
  • Google Login
  • Twitter Login
  • Email / Password Login
  • and so on


Email & Password

No further settings needed. Just activate this handler.


No further settings needed. Just activate this handler.


In order to activate the Facebook Login Handler you have to create a Facebook App first. If you need help with that, please visit this guide.

  Create a Facebook App

If you already have a Facebook App, just login to Facebook Developers and copy the APP ID and the APP SECRET…


…and paste it at Firebase.


Then copy the …/auth/handler  (blue marked) URL and paste it at your Facebook App.



In order to activate the Twitter Login Handler you have to create a Twitter App first.

  Create a Twitter App

Copy your APP ID and your APP SECRET and paste it at Firebase.


Then copy the Auth URL and paste it at your Twitter App (Settings Tab).


OAuth Redirection

If you are using Social Handlers (Facebook, Google, …) add your domain to the list below. Otherwise the login will be blocked and you’ll get this error message in the browser console.

c2runtime.js:16221 Auth: Login failed with following error message: “This domain is not authorized for OAuth operations for your Firebase project. Edit the list of authorized domains from the Firebase console.”


So just add the domain where your game is running on to the list below.


For Scirra Arcade

If you want to add games on Scirra Acarde using Firebase Authentifiaction please note, that Scirra is blocking cross-platform request. Therefor the login with Social Handlers do not work there.

Realtime Database

Firebase offers a realtime database for your game / app. The structure of it can be created in Construct 2 via the Firebase plugin. However to assure that only the data owner can read and write its data, we need to add some rules to the database.


"rules": {
".read": "auth != null",
".write": "auth != null"


Above shown is the default code for the rules. This says that only logged in user can access the data from the database.


"rules": {
"users": {
"$user_id": {
// grants write access to the owner of this user account
// whose uid must exactly match the key ($user_id)
".write": "$user_id === auth.uid",
".read": "auth != null && auth.uid == $user_id"


But in order to differ the data for each user, we have to add following code (more information can be found in the docs of Firebase). So overwrite the default rule with the rules shown above.

Just to let you know...

This will assure that the user can see and write only his/her own data. This also will need some modification in the C2 code, but more later.

Construct 2

At the moment there is now mobile Firebase plugin for Construct 2 available. Only for HTML5 games.

Thank you!

The Firebase plugins for Construct 2 were made by Rexrainbow! Thank you for your hard work.

Live Demo

If you want to check out a live demo of the Firebase Service, please visit following link (Scirra Acarde).

  Game Templat 14 - Cloud Data Sync with Firebase (WEB)
Please note...

Scirra is blocking the Google Login. Please use the Email & Password Login Method instead.


If you want to use Firebase you’ll need to add at least following plugins made by Rexrainbow.

Firebase API V3

0.00 KB 475 downloads

Firebase Core

0.00 KB 343 downloads

Firebase Query

1 MB 359 downloads


Download and install all the core plugins listed above. Those are needed to open the example files.


Additionally you can download and install following plugins made by Rexrainbow.

Firebase Geofire

0.00 KB 399 downloads

Firebase Storage

0.00 KB 228 downloads

Firebase Single Login

0.00 KB 217 downloads

Firebase Timer

0.00 KB 204 downloads

Firebase Counter

0.00 KB 216 downloads

Firebase Itemmonitor

0.00 KB 193 downloads

Firebase Itembook

1 MB 197 downloads
Looking for more?

If you are looking for more awesome plugins & behaviors made by rexrainbow, visit his website over here.

Capx Examples

You can download a complete Firebase Template in the Scirra Store.

  Firebase - Game Accounts

Firebase API


In order to get your ID’s for the Firebase API v3 Plugin, select your Project in Firebase and click on the little gear icon (next to your Project Name) and then Project Settings.


Then scroll down and download the “google-services” JSON-file. There you’ll find all needed ID’s to configure the Firebase API v3 plugin.


Open the JSON-file with an editor of your choice.


Copy the corresponding ID’s from the JSON-file to the Firebase API v3 Plugin.

  • (1) API Key: Copy the as it is from the JSON-File
  • (2) Auth Domain: Copy it WITHOUT https://
Just to be sure...

If your Auth Domain is https://2625623625982.firebaseio.com, then copy 2625623625982.firebaseio.com

  • (3) Database URL: Copy it WITH https://
Just to be sure...

The Database URL is the same then the “firebase_url”, so if the firebase url is https://2625623625982.firebaseio.com, then copy https://2625623625982.firebaseio.com

  • (4) Storage Bucket: Copy it as it is


Updated on May 6, 2018

Was this article helpful?

Related Articles

Need Support?
Can’t find the answer you’re looking for? Don’t worry we’re here to help!
Contact Support


    1. Hi,

      Just see the screenshot above in the guide. You can download the json file with your ID’s out of your Firebase project.


        1. Just go to firebase and select your project. Then click on settings, there you’ll find the file 🙂


          1. i see in my project
            -login & auth

            but no settings

  1. Just to add something that took me a while to figure out…the auth domain ends in *firebaseapp.com…if you see local host under OAuth redirect domains (Auth Tab) it’s the address below. Thanks for this tutorial.

  2. Hello I’m new to firebase concept and I do no that How to use the firebase in construct 2? I am working on cricket project in construct 2 tell me that how can I make it as multiplayer one using firebase

    1. Hi,
      I haven’t made a game using Firebase for multiplayer, so I can’t tell you how to do it. It’s better if you ask that question in the scirra forum.


  3. Thanks, that’s incredibly helpful.

    I want to send variables (questionnaire answers) to the Firebase database. Any suggestion what the best way it to do so?

  4. I’m getting an error of: “TypeError: Cannot read property ‘name’ of null(…)”

    Claims there is an issue with Line 49 Col 27 of the runtime.js and cannot read “database”.

    It might be a problem to bring to RexRainbow, but thought I’d try here first. I’ve played around with the account information entries and nothing seem to change the error, only deleting the V3 plugin works.

    1. Okay, I ended up uninstalling all the Firebase plugins and then shutting down C2. Restarted C2 and added the V3 API plugin, no problem.

      Of course then I added the Auth plugin and got an error but I think I know what is wrong there.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Privacy Preferences

Strictly Necessary

Cookies that are necessary for the site to function properly.

gdpr,PYPF, woocommerce_cart_hash, woocommerce_items_in_cart, _wp_wocommerce_session,gaoop_hide_info,cookieconsent_dismissed, wordpress_,'g-recaptcha-response

Google Adsense (Google Inc.)

We are using Google AdSense to show personalized ads on our webpage and our forum. For more information see the privacy policy by Google.

Doubleclick, __gads, __gac