server less real-time online visitors counter with firebase Realtime database
you can implement in any javascript based frontend/html/react js/angular js
just replace the config object with your own
Real-time online visitors counter using firebase realtime database
- create firebase project https://firebase.google.com/docs/web/setup
- goto firebase realtime database and create a new one.
- navigate to rules tab and add rules like this.
{
"rules": {
".read": false,
".write": false,
"tempUser":{
".read":true,
".write":true,
".indexOn":"state"
}
}
}
- now goto html/index.html
- replace firebaseConfig with your own
var firebaseConfig = {
apiKey: "API_KEY",
authDomain: "PROJECT_ID.firebaseapp.com",
databaseURL: "https://PROJECT_ID.firebaseio.com",
projectId: "PROJECT_ID",
storageBucket: "PROJECT_ID.appspot.com",
messagingSenderId: "SENDER_ID",
appId: "APP_ID",
measurementId: "G-MEASUREMENT_ID",
};
- run index.html
- run
npm i
- open config.js file
- replace firebaseConfig with your own
var firebaseConfig = {
apiKey: "API_KEY",
authDomain: "PROJECT_ID.firebaseapp.com",
databaseURL: "https://PROJECT_ID.firebaseio.com",
projectId: "PROJECT_ID",
storageBucket: "PROJECT_ID.appspot.com",
messagingSenderId: "SENDER_ID",
appId: "APP_ID",
measurementId: "G-MEASUREMENT_ID",
};
- run
npm start