How can we integrate Firebase Hosting with Firebase Realtime Database / Storage?

落花浮王杯 提交于 2020-01-15 10:28:58

问题


Now that Firebase provides Web Hosting services, how can we integrate Firebase Hosting with Firebase Realtime Database and Firebase Storage?


回答1:


Firebase Hosting is static hosting for your web app.So you can use HTML, CSS, JavaScript.

JavaScript Code:

<script src="https://www.gstatic.com/firebasejs/3.5.0/firebase.js"></script>
<script>
  // Initialize Firebase
  // TODO: Replace with your project's customized code snippet
  var config = {
    apiKey: "<API_KEY>",
    authDomain: "<PROJECT_ID>.firebaseapp.com",
    databaseURL: "https://<DATABASE_NAME>.firebaseio.com",
    storageBucket: "<BUCKET>.appspot.com",
    messagingSenderId: "<SENDER_ID>",
  };
  firebase.initializeApp(config);

  // Get a reference to the database service
  var database = firebase.database();


 // Get a reference to the storage service, which is used to create
 references in your storage bucket

  var storage = firebase.storage();

</script>

For More See:

  • https://firebase.google.com/docs/web/setup
  • https://firebase.google.com/docs/hosting/


来源:https://stackoverflow.com/questions/40188552/how-can-we-integrate-firebase-hosting-with-firebase-realtime-database-storage

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!