Firebase does not work in China
Firebase does not work in China

TLDR; This Firebase China article provides you with a the best solutions to get your Firebase applications working fast, stable, and compliant in China.


What is Firebase and how it works??

Firebase is a real-time back-end database startup company that can help developers quickly write web and mobile applications. In October 2014, Google acquired Firebase and later integrated Firebase into Google’s cloud services.


Does Firebase work in China?

No. Firebase does not have servers in mainland China, making their services unstable or inaccessable in China.

If you want to learn a solution to accelerate Firebase in China, please refer to this Firebase China article, where we dive deeper into how Firebase works in China and how to accelerate Firebase in China.

If you prefer to keep your application hosted on servers in mainland China, we recommend using Parse.


The Best Alternative for Firebase in China is Parse

Parse Official Website
Parse Official Website


What is Parse?

Parse is a cloud-based back-end management platform.

Parse provides developers a one-stop back-end and package services, including server configuration, database management, API, video and audio file storage, real-time message push, customer data analysis, and statistics, etc. Parse enables developers to focus on the front-end/client/mobile-side development by helping to manage the back-end for you.

Facebook acquired Parse in 2013, and later decided to close Parse, and finally, Parse decided to open source their code, and now Parse Server and Parse Dashboard, and recently GraphQL Other functions.

21YunBox provides an operational and maintenance-free, single-click Parse Dashboard deployment solution.


How to Create and Deploy a Parse Server?

  1. Signup on 21YunBox
  2. Create a MongoDB database
  3. Fork Parse Server starter
  4. Click Cloud Service on 21YunBox and allow 21YunBox to access your repo
  5. Use the following values during the creation
Runtime Node
Build command yarn install
Start command yarn start

Click Advanced Configuration to configure environment variables:

KEY VALUE
APP_ID Randomly generate 32-bit characters
MASTER_KEY Randomly generate 32-bit characters
MONGODB_URI Click Database URL in the cloud database console to obtain
SERVER_URL https://<APP_ID>.21cloudbox.com/parse
PORT 10000, default port used by 21CloudBox

For more other Parse Server environment variable configurations, please refer to the official documentation.

Randomly generate 32-bit characters method: Paste the following command on the command line:

echo $(base64 /dev/urandom | head -c32)

After Parse is successfully deployed, you can go to <APP_ID>.21cloudbox.com/test for testing. When the test is successful, you will see the following:

Parse deployed successfully
Parse deployed successfully

Step-by-Step Setup and Deploy Video:

Firebase Alternative-how to deploy Parse to the server



How to use Parse Server to Create and Read Data?

You can use the curl command or the visual interface Postman to help you create and read data.


Create Data

Created in curl way

curl -X POST \
-H "X-Parse-Application-Id: <APPLICATION_ID>" \
-H "Content-Type: application/json" \
-d'{"score":1337,"playerName":"Sean Plott","cheatMode":false}' \
https://<APP_ID>.21cloudbox.com/parse/classes/GameScore

After the successful creation, you should receive a similar json

{
    "objectId": "9ed7LlOzn2",
    "createdAt": "2021-03-25T07:03:28.668Z"
}


Read Data

Via objectId, read the data created above

curl -X GET \
  -H "X-Parse-Application-Id: APPLICATION_ID" \
  https://<APP_ID>.21cloudbox.com/parse/classes/GameScore/9ed7LlOzn2
// Response
{
    "objectId": "9ed7LlOzn2",
    "score": 1337,
    "playerName": "Sean Plott",
    "cheatMode": false,
    "createdAt": "2021-03-25T07:03:28.668Z",
    "updatedAt": "2021-03-25T07:03:28.668Z"
}


Create and read data demos with Postman:

Firebase domestic alternative-create and read data with Postman

In addition to the simple method of using curl or Postman to create data above, Parse also provides a multi-language SDK (iOS, Android, PHP, etc.). For more details, please refer to the official Parse documentation at http://docs.parseplatform.org/