Supported environments
The Firebase JavaScript SDK is officially supported in the following environments.
Browsers
| Firebase product | Edge | Firefox | Chrome | iOS Safari | Safari |
|---|---|---|---|---|---|
| Firebase AI Logic 1 | |||||
| Analytics | |||||
| App Check | |||||
| Authentication | |||||
| Cloud Firestore | (except persistence) |
(except persistence if iOS < 10) |
|||
| Cloud Functions | |||||
| Cloud Messaging | (Edge 17+, except mobile) |
||||
| Cloud Storage | |||||
| Crashlytics | |||||
| Firebase installations | |||||
| Performance Monitoring | |||||
| Realtime Database | |||||
| Remote Config | |||||
| SQL Connect |
1 Firebase AI Logic was formerly called "Vertex AI in Firebase".
Other environments
| Firebase product | React Native | Node.js (18+) | Chrome Extensions |
Cordova |
|---|---|---|---|---|
| Firebase AI Logic 1 | ||||
| App Check | (using a custom provider to do native device attestation) |
(using a custom provider) |
||
| Analytics | ||||
| Authentication | (see Note) |
(see Note) |
(see Note) |
(see Note) |
| Cloud Firestore | (except persistence) |
(except persistence) |
||
| Cloud Functions | ||||
| Cloud Messaging | ||||
| Cloud Storage | (except uploads) |
|||
| Crashlytics | ||||
| Firebase installations | ||||
| Performance Monitoring | ||||
| Realtime Database | ||||
| Remote Config | ||||
| SQL Connect |
1 Firebase AI Logic was formerly called "Vertex AI in Firebase".
Content Security Policy and Trusted Types
Some Firebase products load external scripts by adding <script> elements to
your page:
| Firebase product | Scripts loaded |
|---|---|
| Analytics |
|
| App Check |
|
| Authentication |
|
If your page has a Content Security Policy (CSP), its script-src directive
must allow these scripts.
If your page enforces Trusted Types
with the require-trusted-types-for 'script' CSP directive, the
Firebase JavaScript SDK sets these script URLs through a Trusted Types policy named
firebase-js-sdk-policy. This policy only accepts the script URLs listed
above. If your CSP also uses the trusted-types directive to restrict which
policies can be created, add firebase-js-sdk-policy to it, along with any
other policies that your app uses. For example:
Content-Security-Policy: require-trusted-types-for 'script'; trusted-types firebase-js-sdk-policy
If the policy isn't allowed, these products can't load their scripts, and the SDK logs an error in the console that names the policy to add.
Polyfills
The Firebase JavaScript SDK is built on the latest standards of the web platform. Some older browsers and JavaScript environments do not support all the features required by Firebase. If you must support these browsers/environments, then you need to load polyfills accordingly.
The sections below identify most of the polyfills you might need.
Required polyfills
| Environments | Polyfills |
|---|---|
| Safari 7 & 8 & 9 | ES Stable |
| Node < 10 | ES Stable |
Optional polyfills
| Environments | Polyfills | Firebase products |
|---|---|---|
|
fetch |
|
|
fetch |
|
|
base-64 |
|
Suggested polyfills
| Polyfills | License |
|---|---|
| ES Stable | MIT |
| fetch - `cross-fetch` - best for older browsers | MIT |
| fetch - `undici` - best for Node.js | MIT |
| base-64 | MIT |
Required Polyfill Setup for React Native and Expo
For React Native and Expo if you are uploading a base-64 encoded string, you need to do the following:
Install base-64 from npm:
npm install base-64
Import decode from base-64 and attach it to the global scope as atob so
Cloud Storage can access it.
import { decode } from 'base-64';
if(typeof atob === 'undefined') {
global.atob = decode;
}
Add polyfills in your application
Option 1: (Recommended) Use bundler integrated with Babel
If you're using a bundler, integrate with Babel and @babel/preset-env to get polyfills.
Use Babel's interactive setup guide to learn how to integrate Babel with your bundler.
With Babel, you don't need to worry about the exact polyfills to include. Instead, you specify the minimal browser environments that you need to support. Babel then adds the necessary polyfills for you. Babel ensures that your requirements for browser support are always met, even if Firebase or your own code starts using new ES features.
@babel/preset-env has detailed
information about the available configuration options for specifying environment
targets (option targets) and adding polyfills (option useBuiltIns).
Option 2: (Not Recommended) Add polyfills manually
You can add polyfills manually using your favorite polyfill libraries (for
example, core-js).
import 'core-js/stable'
import 'cross-fetch/polyfill';
core-js also provides an
all-in-one polyfill file
that you can directly include in the HTML page.
This option can be a convenient way for managing polyfills if you don't use Babel. However, we don't recommend this all-in-one option for production apps as it will likely include unnecessary polyfills, which increases the page weight and hence the page load time.