npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@osnova/firebase-client

v0.10.0

Published

It is never (or almost never) a good idea to load Firebase Web SDK synchronously in the browser because of it's enormous size. This package is a thin wrapper over Firebase that allows to load lazily only necessary modules and handles some edge cases.

Downloads

55

Readme

@osnova/firebase-client

It is never (or almost never) a good idea to load Firebase Web SDK synchronously in the browser because of it's enormous size. This package is a thin wrapper over Firebase that allows to load lazily only necessary modules and handles some edge cases.

Features

  • Lazy loading of only necessary modules.
  • Support for Emulator Suite.
  • Use multiple Firebase applications per page.
  • Does not break on HMR.

Install

# npm
npm install @osnova/firebase-client firebase --save
# yarn
yarn add @osnova/firebase-client firebase

Usage

Default export is the function that lazily loads and initializes Firebase:

import startFirebase from '@osnova/firebase-client';

/* Firebase SDK config. Can be retrieved from Firebase Console. 
     https://firebase.google.com/docs/web/setup#register-app */
const config = {
  apiKey: 'apiKey',
  authDomain: 'project.firebaseapp.com',
  databaseURL: 'https://project.firebaseio.com',
  projectId: 'project',
  storageBucket: 'project.appspot.com',
  messagingSenderId: 'messagingSenderId',
  appId: 'appId',
  measurementId: 'measurementId',
};

startFirebase(config, {
  name: `my-firebase-app`,
  use: {
    // specify which modules will be used
    analytics: true,
    auth: true,
    firestore: true,
    storage: true,
    funtions: true,
  },
}).then((app) => {
  // firebase is available and ready to use.
});

Usage with Emulator Suite

By default @osnova/firebase-client will not use to any emulators.

This behaviour can be modified with emulator option:

import startFirebase, { shouldUseEmulatorWhenLocalhost } from '@osnova/firebase-client';

startFirebase(config, {
  /* ...rest config */
  emulator: {
    shouldUseEmulator: shouldUseEmulatorWhenLocalhost, // default value is `() => false`
    firestoreHost: `localhost:8080`, // this is a default value
    authHost: `http://localhost:9099`, // this is a default value
  },
}).then((app) => {
  // firebase is available and ready to use.
});

shouldUseEmulatorWhenLocalhost is a built-in function that detects if application is running on localhost. You can provide your own function:

function shouldUseEmulatorIfEnv() {
  return !!process.env.FIREBASE_EMULATOR;
}

Emulators will be used If options.emulator.shouldUseEmulator return true.

options.emulator.firestoreHost and options.emualator.authHost can accept false value, which means that corresponding emulator will not be used even if shouldUseEmulator returned true.

Development

Release

  1. Bump version in package.json

  2. Run

yarn release