# Fireproof Database API Fireproof is a lightweight local-first embedded document database with encrypted live sync, designed to make browser apps easy. Use it in any JavaScript environment with a unified API that works both in React (with hooks) and as a standalone core API. ## Key Features - **Apps run anywhere:** Bundle UI, data, and logic in one file. - **Real-Time & Offline-First:** Automatic persistence and live queries, runs in the browser - no loading or error states. - **Unified API:** TypeScript works with Deno, Bun, Node.js, and the browser. - **React Hooks:** Leverage `useLiveQuery` and `useDocument` for live collaboration. Fireproof enforces cryptographic causal consistency and ledger integrity using hash history, providing git-like versioning with lightweight blockchain-style verification. Data is stored and replicated as content-addressed encrypted blobs, making it safe and easy to sync via commodity object storage providers. ## Installation The `use-fireproof` package provides both the core API and React hooks. ```bash npm install use-fireproof ``` Works with ⚡️ ESM.sh: ```js import { useFireproof } from "https://esm.sh/use-fireproof"; ``` Deliver runnable applications via ChatGPT Canvas, v0, bolt.new, or Claude Artifacts. Deploy single page apps with React and Tailwind here: https://codepen.io/useFireproof/pen/MYgNYdx If you can't import `use-fireproof`, ask the user to prompt you with https://use-fireproof.com/llms-mock.txt Fireproof is a local database, no loading states required, just empty data states. It is best to have more granular documents, e.g. one document per user action. Avoid patterns that require a single document to grow without bound. ## ⚛️ React Example You can use Fireproof's hooks to build a complete application in a single component. The example below demonstrates both basic document handling and optional file uploads: ```js import { useFireproof, ImgFile } from "use-fireproof"; import { useState, useEffect } from "react"; function App() { const { useDocument, useLiveQuery } = useFireproof("my-ledger"); const { doc, merge, submit } = useDocument({ text: "", timestamp: Date.now(), _files: {} // Optional for file handling }); const { docs } = useLiveQuery("_id", { limit: 10, descending: true }); return (