百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
F

firestorter

> 前端框架
开源

使用 MobX 在 React 中使用 Google Firestore 并使用零努力

378 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

使用 MobX 在 React 中使用 Google Firestore 并使用零努力

Firestorter

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.

bash
yarn add firestorter

1. Initialize

javascript
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

javascript
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

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

const Todos = observer(() => {
  return 
;
});

const TodoItem = observer(({doc}) => {
  const { finished, text } = doc.data;
  return 
;
});

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

  • Add, update & delete documents
  • Super efficient Component re-rendering
  • Declaratively link document/collection paths to document data
  • Geo query support
  • Easily create aggregate collections from multiple queries
  • Runtime schema validation & Type Generics
  • Manual fetching mode for use with Unit-tests/Async-functions
  • React-native support
  • TypeScript- & Flow typings
  • Works with Vue.js

Want to learn more, head over to the docs

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

TypeScriptfirestore-collectionfirestore-mobxfirestore-modelsfirestore-react

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架