Firebase is back at Cloud Next on April 9 - 11. Register now.
(https://cloud.withgoogle.com/next/25?
utm_source=firebase&utm_medium=&utm_campaign=svd_firesite_banner&utm_content=)
Alternative ways to add Firebase to your
JavaScript project
For most Firebase Web apps we strongly recommend using the SDK via npm (/docs/web/setup).
However, for users with special requirements, Firebase provides alternative ways to add the SDK
(/docs/web/learn-more#ways-to-add-web-sdks). This page provides detailed setup instructions for these
alternative methods:
CDN (content delivery network)
npm for Node.js apps
Using these methods, you can add any of the available libraries
(/docs/web/learn-more#available-libraries) to your app.
From the CDNNode.js apps (#node.js-apps)
(#from-the-cdn)
You can configure partial import of the Firebase JavaScript SDK and only load the Firebase
products that you need. Firebase stores each library of the Firebase JavaScript SDK on our
global CDN (content delivery network).
1. To include only specific Firebase products (/docs/web/learn-more#libraries-cdn) (for
example, Authentication and Cloud Firestore), add the following script to the bottom of
your <body> tag, but before you use any Firebase services:
<body>
<!-- Insert this script at the bottom of the HTML, but before you use any
<script type="module">
import { initializeApp } from 'https://www.gstatic.com/firebasejs/11.3
// If you enabled Analytics in your project, add the Firebase SDK for G
import { getAnalytics } from 'https://www.gstatic.com/firebasejs/11.3.1
// Add Firebase products that you want to use
import { getAuth } from 'https://www.gstatic.com/firebasejs/11.3.1/fire
import { getFirestore } from 'https://www.gstatic.com/firebasejs/11.3.1
</script>
</body>
star You can optionally delay loading of Firebase SDKs (/docs/web/learn-more#delay-sdks-cdn) until the
entire page has loaded.
2. Add your Firebase configuration object, and then initialize Firebase in your app:
<
<
>
>
// TODO: Replace the following with your app's Firebase project configu
const firebaseConfig = {
// ...
};
// Initialize Firebase
const app = initializeApp(firebaseConfig);
<
>
<
>
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License
(https://creativecommons.org/licenses/by/4.0/), and code samples are licensed under the Apache 2.0 License
(https://www.apache.org/licenses/LICENSE-2.0). For details, see the Google Developers Site Policies
(https://developers.google.com/site-policies). Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-02-13 UTC.