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

firestorter

v4.0.1

Published

Simple & super fast Firestore to React bindings using Mobx observables

Downloads

502

Readme

Build Status codecov MIT licensed code style: prettier Release Notes Donate

Use Google Firestore in React with zero effort, using MobX 🤘

  • 🎶 Simple, easy to use API, get up & running in minutes
  • 🚀 Fast, only fetches and re-renders data when needed
  • 🤘 No clutter, no complex stores/providers/actions/reducers, just go

The latest version is compatible with the Firebase v9 API.

yarn add firestorter

1. Initialize

import { initializeApp } from 'firebase/app';
import { getFirestore } from 'firebase/firestore';
import { initFirestorter } from 'firestorter';
import makeWebContext from 'firestorter/web';

// Initialize firebase app
const app = initializeApp({ ... });
const firestore = getFirestore(app);

// Initialize `firestorter`
initFirestorter(makeWebContext({ firestore }));

See here on how to use with react-native, compat mode and older firebase SDKs.

2. Create a Collection or Document

import { Collection, Document } from 'firestorter';

const todos = new Collection('todos');
const user = new Document('users/8273872***');

3. Wrap your Components with mobx's observer pattern

import * as React from 'react';
import { observer } from 'mobx-react';

const Todos = observer(() => {
  return <div>
    {todos.docs.map((doc) => (
      <TodoItem
        key={doc.id}
        doc={doc} />
    ))}
  </div>;
});

const TodoItem = observer(({doc}) => {
  const { finished, text } = doc.data;
  return <div>
    <input type='checkbox' checked={finished} />
    <input type='text' value={text} />
  </div>;
});

That's it. Your Components will now render your firestore data and re-render when data in the back-end changes.

How it works

Firestorter makes integrating Firestore real-time data into React easy as pie. It does this by providing a simple API for accessing Collection and Document data, whilst taking away the burden of managing snapshot listeners, data-caching and efficiently updating your React components.

It does this by intelligently tracking whether a Collection or Document should be listening for real-time updates (onSnapshot events) or not. Whenever a Component renders a Collection or Document, firestorter enables real-time updates on that resource. And whenever a Component stops using the resource (e.g., component was unmounted), it stops listening for snapshot updates. This behavior really shines when multiple components are rendering collection/document data and it becomes more difficult to determine whether snapshot updates should be enabled or not.

Features

Want to learn more, head over to firestorter.com 🤘