# Services : Firebase : JS Packages #### Primary Packages There are two primary packages for using Firebase services in your apps: - `firebase` — aka _”Web SDK”_ - for clients (user-level access) - works on browsers _and_ Node, but with slightly different feature subsets - `firebase-admin` — aka _”Node.js Admin SDK”_ - for servers (admin-level access) - lots of overlap with `firebase` features, but a smaller subset (appropriate for servers) #### The Four Dualities There are four levels of duality at play here, which can be confusing: 1. The duality between the `firebase` and `firebase-admin` packages. 2. Within the `firebase` package, there’s two “styles” of API: a. the old _“namespaced”_ style (`import firebase from "firebase/compat/app"`) b. the new _“modular”_ style (`import { initializeapp } from "firebase/app"`) 3. Within the new _“modular”_ style, there’s two levels of code: a. the first level are folders in the `firebase` package, like `“firebase/auth"`, where functions are imported from b. the second level are the modular packages that are imported and used by the first level, like `@firebase/auth`, which actually implement all the logic, and are pulled in as dependencies 4. Finally, there’s also minor differences in the features provided by `firebase` depending on whether it finds itself running inside a browser or node environment. 5. BONUS: In addition to all that, when you’re writing a Firebase Cloud Function, you'll also need the `firebase-functions` package, which provides features needed for that purpose. (This is different from the features provided by the `firebase/functions` folder in the `firebase` and `firebase-admin` packages.) #### CLI & Emulator Suite The `firebase-tools` package contains the CLI, which can be used to... - …create/manage Firebase services - …create/develop/manage Firebase projects - …run the Firebase Emulator Suite for development & testing - …deploy stuff to Firebase #### Choosing | | Client-Side Apps | Server-Side Apps | Cloud Functions | | ---------------------------------------------- | :--------------: | :--------------: | :-------------: | | `firebase` | ✅ | | | | `firebase-admin` | | ✅ | ✅ | | `firebase-functions`<br>peer: `firebase-admin` | | | ✅ | | `firebase-tools` | ✅ | ✅ | ✅ | #### References - [firebase](https://www.npmjs.com/package/firebase "https://www.npmjs.com/package/firebase") ( [src](https://github.com/firebase/firebase-js-sdk/tree/master/packages/firebase "https://github.com/firebase/firebase-js-sdk/tree/master/packages/firebase") | docs: [modular-style](https://firebase.google.com/docs/reference/js/ "https://firebase.google.com/docs/reference/js/") | [namedspaced-style](https://firebase.google.com/docs/reference/js/v8/ "https://firebase.google.com/docs/reference/js/v8/") ) - [@firebase/app](https://www.npmjs.com/package/@firebase/app "https://www.npmjs.com/package/@firebase/app") ( [src](https://github.com/firebase/firebase-js-sdk/tree/master/packages/app "https://github.com/firebase/firebase-js-sdk/tree/master/packages/app") ) - [firebase-admin](https://www.npmjs.com/package/firebase-admin "https://www.npmjs.com/package/firebase-admin") ( [src](https://github.com/firebase/firebase-admin-node/ "https://github.com/firebase/firebase-admin-node/") | [docs](https://firebase.google.com/docs/reference/admin/node "https://firebase.google.com/docs/reference/admin/node") ) - [firebase-functions](https://www.npmjs.com/package/firebase-functions "https://www.npmjs.com/package/firebase-functions") ( [src](https://github.com/firebase/firebase-functions/ "https://github.com/firebase/firebase-functions/") | docs: [1st-gen](https://firebase.google.com/docs/reference/functions/firebase-functions "https://firebase.google.com/docs/reference/functions/firebase-functions") | [2nd-gen](https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions "https://firebase.google.com/docs/reference/functions/2nd-gen/node/firebase-functions") ) - [firebase-tools](https://www.npmjs.com/package/firebase-tools "https://www.npmjs.com/package/firebase-tools") ( [src](https://github.com/firebase/firebase-tools/ "https://github.com/firebase/firebase-tools/") | docs: [setup](https://firebase.google.com/docs/cli "https://firebase.google.com/docs/cli") | [commands](http://firebaseopensource.com/projects/firebase/firebase-tools/ "http://firebaseopensource.com/projects/firebase/firebase-tools/") )