Localbase is a JavaScript library providing a Firebase Cloud Firestore-like API for an offline, browser-based database powered by IndexedDB. It simplifies local data persistence, allowing developers to manage data in collections and documents without direct interaction with the complexities of IndexedDB. The current stable version is 0.7.7. Releases appear somewhat irregularly, primarily addressing bug fixes, compatibility issues (e.g., Vite environment), and new features like collection filtering. Its key differentiators include its familiar API for developers accustomed to Firebase, robust offline capabilities, and its foundation on LocalForage, which handles cross-browser IndexedDB inconsistencies. It also ships with TypeScript type definitions for improved developer experience.
npm install localbaseVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize Localbase, add a new document to a collection, update an existing document, and retrieve data from a collection and a specific document using async/await.
Upgrade to `localbase@^0.7.6` or later: `npm install localbase@latest`.
Use `.add()` to insert new documents or `.update()` to partially modify existing documents. Only use `.set()` when you explicitly want to replace the entire document or collection.
Always `await` Localbase operations in an `async` function, or chain with `.then()` and `.catch()` for proper control flow and error handling.
Upgrade Localbase to version 0.7.6 or newer (`npm install localbase@latest`) and ensure you are using ESM `import Localbase from 'localbase'`.
Ensure `localbase` is correctly imported as a default export (`import Localbase from 'localbase'`). Verify `tsconfig.json` includes `"dom"` in `lib` and `"node_modules/@types"` in `typeRoots` or that `@types/localbase` is not conflicting (though localbase ships its own types).
Always use `await` with Localbase operations or chain with `.then()` to ensure data operations complete before any dependent actions or page navigations occur. Verify the browser's IndexedDB for your application to confirm data is written.