use-fireproof
TypeScript icon, indicating that this package has built-in type declarations

0.17.11 • Public • Published

Fireproof logo Fireproof realtime database

Package size Build status

No setup: write features first, access your data anywhere

Add collaboration to any app with Fireproof. Access data from JavaScript servers and edge functions. Use live queries to update your UI automatically when the database changes. Connect realtime sync and those changes will sync between browsers and backend functions. Apps built this way are multi-player by default.

JavaScript quick start

The document database API will feel familiar. Queries use dynamic indexes, and the database can refresh your UI, as seen in the db.subscribe call below, as well as the React liveQuery hook.

import { fireproof } from '@fireproof/core'

const db = fireproof('music-app')

await db.put({ _id: 'beyonce', name: 'Beyoncé', hitSingles: 29 })

db.subscribe(async () => {
  const topArtists = await db.query("hitSingles", { range: [30, Infinity] })
  // redraw the UI with the new topArtists
})

const beyonceDoc = await db.get('beyonce')
beyonceDoc.hitSingles += 1
await db.put(beyonceDoc)

Jump to the docs site for JavaScript API basics.

Live data hooks for React

Fireproof React hooks for live data avoid boilerplate and make building collaborative apps a breeze.

import { useLiveQuery, useDocument } from 'use-fireproof'

function App() {
  const completedTodos = useLiveQuery('completed', { limit: 10 })
  const [newTodo, setNewTodoData, saveNewTodo] = useDocument({type: 'todo', text: '', completed: false, created: Date.now() })

Read the step-by-step React tutorial to get started.

Why choose Fireproof

Compared to other embedded databases, Fireproof:

  • is network aware, encrypted, and multi-writer safe
  • is designed for real-time collaboration with CRDTs
  • offers cryptographic causal integrity for all operations
  • is built for the web, with a small package size and no wasm

Deliver interactive experiences without waiting on the backend. Fireproof runs in any cloud, browser, or edge environment, so your application can access data anywhere.

Get the latest roadmap updates on our blog or join our Discord to collaborate. Read the docs to learn more about the database architecture.

Use cases

Fireproof allows web developers to build full-stack apps. It's especially useful for:

  • Rapid prototyping
  • AI copilot safety
  • Collaborative editing
  • Personalization and configuration
  • Offline and local-first apps

With Fireproof, you build first and sync via your cloud of choice when you are ready, so it's as easy to add to existing apps as it is to build something new. Drop Fireproof in your page with a script tag and start sharing interactive data.

Fireproof is a great fit for code sandboxes and online IDEs, as you can get started without any configuration. This also makes it easy for AI to write Fireproof apps.

Install

Get started with the React hooks:

npm install use-fireproof

or install the database in any JavaScript environment:

npm install @fireproof/core

The default build is optimized for browsers, to load the node build add /node:

import { fireproof } from '@fireproof/core/node'

Add the database to any web page via HTML script tag (global is Fireproof):

<script src="https://cdn.jsdelivr.net/npm/@fireproof/core/dist/browser/fireproof.global.js"></script>

Go ahead and write features, then connect to any cloud backend later.

Thanks 🙏

Fireproof is a synthesis of work done by people in the web community over the years. I couldn't even begin to name all the folks who made pivotal contributions. Without npm, React, and VS Code all this would have taken so much longer. Thanks to everyone who supported me getting into database development via Apache CouchDB, one of the original document databases. The distinguishing work on immutable data-structures comes from the years of consideration IPFS, IPLD, and the Filecoin APIs have enjoyed.

Thanks to Alan Shaw and Mikeal Rogers without whom this project would have never got started. The core Merkle hash-tree clock is based on Alan's Pail, and you can see the repository history goes all the way back to work begun as a branch of that repo. Mikeal wrote the prolly trees implementation.

Contributing

We love contributions. Feel free to join in the conversation on Discord. All welcome.

License

Dual-licensed under MIT or Apache 2.0

Package Sidebar

Install

npm i use-fireproof

Weekly Downloads

25

Version

0.17.11

License

Apache-2.0 OR MIT

Unpacked Size

2.77 MB

Total Files

10

Last publish

Collaborators

  • jchris