score:0
see https://firebase.google.com/docs/web/setup#add-sdks-initialize
how you add firebase sdks to your app depends on whether you've chosen to use firebase hosting for your app, what tooling you're using with your app (like a bundler), or if you're configuring a node.js app.
- from hosting urls
- from the cdn
- using module bundlers
- node.js apps
if you use reserved hosting urls, your firebase config is automatically pulled from your firebase project, so you don't need to explicitly provide the object in your code.
it is in case of from hosting urls
only.
initialize firebase in your app (no need to include your firebase config object when using reserved hosting urls):
and you should initialize firebase like the following code.
<body>
<!-- previously loaded firebase sdks -->
<!-- initialize firebase -->
<script src="/__/firebase/init.js"></script>
</body>
you can see a __/firebase/init.js
sample https://friendly-pix.com/__/firebase/init.js
from hosting urls
samples:
- https://github.com/firebase/quickstart-js/blob/master/database
- https://github.com/firebase/quickstart-js/blob/master/database/index.html#l144
- https://github.com/firebase/codelab-friendlychat-web/tree/master/web
- https://github.com/firebase/codelab-friendlychat-web/blob/master/web/public/index.html#l121
could you check the other samples?
score:0
for the firebase sdks to be able to find your firebase project on the servers, it needs certain configuration data. there are multiple ways for it to get this data. in your scenario the two relevant ways are:
- you can specify the configuration data inside your code with a snippet of json that you copy from the firebase console
- when you use the firebase emulators and/or deploy to firebase hosting, it can automatically get the configuration data through a "magic" file called
/__/firebase/init.js
both these options are also listed in documentation on adding the firebase sdks to a web app under from hosting urls and from the cdn. from that documentation, this is how you auto-configure the loaded sdk:
<body>
<!-- previously loaded firebase sdks -->
<!-- initialize firebase -->
<script src="/__/firebase/init.js"></script>
</body>
Source: stackoverflow.com
Related Query
- Firebase Realtime Database setup with hosting URLS
- Delete file on realtime Database on Firebase with React.js
- How can I setup Firebase hosting multisites with Nextjs
- React-Bootstrap table with firebase realtime database creates new table for each entry
- How to properly store data from Firebase Realtime Database and render it with React once it has been retrieved?
- how to properly handle firebase realtime database listeners with useEffect?
- Fetching in Firebase Realtime Database with React Js
- Bootstrap-table displays both "No matching records found" and Records in bootstrap-table with Firebase realtime database
- Populate React Table with firebase realtime database data
- Firebase hosting with react router
- Firebase hosting + React with webpack
- Trouble with deep routes on a single-page app on Firebase hosting
- Using Firebase with React in Firebase Hosting
- Redux Store does not update state with created data on firebase real-time database
- Firebase Realtime Database - "Error: Client is offline". React/NextJS
- How to use sitemap in firebase hosting with react app
- How to improve firebase real time database rules with anonymous user
- how to fetch data from firebase realtime database in react js
- How to check if name already exists in Firebase Realtime Database (Firebase & JS)
- reading firebase database with an onCreate()
- How fetch data from firebase realtime database in react js
- Absolute paths for React app on Github CI with Firebase hosting
- Store Increment Counter In Firebase Cloud Firestore or Realtime Database
- React+Firebase: How to add item to list data into firebase realtime database
- Write fetched data to variable from firebase realtime database react
- query from firebase realtime database
- How To Store Firebase Realtime Database Object In UseState In React
- Unable to interact with firebase real time database emulator
- React with firebase cloud firestore- presenting data from the database
- Firebase Hosting Automatic Cache Busting with Bundle hash change in .js file /service-worker.js
More Query from same tag
- componentWillMount for react functional component?
- React how to apply`componentDidMount()
- How to extract selectors from adapter from queries with arguments
- react write file: nothing works (fs, file-system...)
- how to get redux state in setInterval
- Module not found: Can't resolve '../styles/global.css' in an next.js project
- REACT / AG-GRID: Dynamically setting columnDefs after retrieving data
- react cannot update state with easy peasy
- Is there a way to access a React component's sub-components?
- Webpack 4, process is not defined
- Electron/React: How to use IPC to run Global Shortcut uninterrupted
- i want react hook cascading select option
- Add support for next-css and next-less simultaneously in next.config.js
- How can I import JavaScript file downloaded from `npm` or `yarn` to client (browser)?
- Material UI <TextField/> not Vertical Align with it's Label
- Update User Context After Attribute Update - AWS Amplify
- How to change an array element in state in a React
- Page loads before user data is saved from useEffect() to useContext() in React.js
- Align Right Menu of Antd from Layout Component
- How to set React component state and props from browser
- Return isn't executed - Javascript, React.js
- Can't delete item using ReactJs MongoDB NodeJS
- How can I edit the value of the timepicker from the keyboard?
- How to calculate numbers within an array of objects
- Adding css transitions to a growing list of items
- How to Change a css property based on a state of another component
- block the refresh of the date when submitting the form
- Open the url in the next page by adding the text of input field in Reactjs
- change state of clicked target inside mapped array
- Imitate user input in a React controlled input