# InstantDB — Real-Time Database for Modern Apps > InstantDB provides a client-side synced database with auth, permissions, and presence built in, letting you ship reactive apps without writing backend code. ## Install Save in your project root: # InstantDB — Real-Time Database for Modern Apps ## Quick Use ```bash npm install @instantdb/react ``` ```jsx import { init, tx, id } from '@instantdb/react'; const db = init({ appId: 'YOUR_APP_ID' }); function App() { const { data } = db.useQuery({ todos: {} }); const addTodo = () => db.transact(tx.todos[id()].update({ text: 'New todo' })); return
{data?.todos?.map(t =>

{t.text}

)}
; } ``` ## Introduction InstantDB is a real-time database that syncs data between client and server instantly. It combines a graph-based data model with built-in authentication, permissions, and presence, so developers can build collaborative apps without managing a traditional backend. ## What InstantDB Does - Syncs data in real-time between all connected clients with optimistic updates - Provides a graph-based relational data model with link and unlink operations - Includes built-in auth (email magic links, Google OAuth) and row-level permissions - Offers presence and cursor tracking for multiplayer experiences - Works offline with a local cache that reconciles when connectivity returns ## Architecture Overview InstantDB runs a server that maintains a triplestore-inspired data model where entities and relationships are first-class. The client SDK maintains a local replica using a reactive query engine. Mutations are applied optimistically on the client and confirmed by the server via WebSocket. Conflict resolution uses a last-writer-wins strategy with server-authoritative ordering. ## Self-Hosting & Configuration - Sign up at instantdb.com to get an app ID (cloud-hosted) - Install the SDK: `npm install @instantdb/react` or `@instantdb/core` - Define permissions in the InstantDB dashboard using InstaQL rules - Set up auth providers in the dashboard configuration - Use the CLI for schema management: `npx instant-cli push-schema` ## Key Features - Optimistic mutations that feel instant to users with automatic rollback on conflict - InstaQL query language for traversing relationships with nested joins - Built-in presence API for showing who is online and what they are viewing - TypeScript-first SDK with full type inference from your schema - Transactions that batch multiple mutations atomically ## Comparison with Similar Tools - **Firebase Realtime Database** — similar real-time sync, but uses a JSON tree model instead of a relational graph - **Supabase** — PostgreSQL-based, more traditional SQL, requires more backend setup - **Convex** — server-side functions with real-time sync, more opinionated about backend logic - **PocketBase** — self-hosted, single-binary, but lacks real-time graph queries ## FAQ **Q: Can I self-host InstantDB?** A: The project is open source. Self-hosting documentation is available for running your own instance. **Q: What frameworks are supported?** A: Official SDKs exist for React, React Native, and vanilla JavaScript. Community wrappers cover Vue and Svelte. **Q: How does it handle offline usage?** A: The client SDK caches data locally and queues mutations. When the connection restores, it syncs changes automatically. **Q: Is there a row limit or pricing tier?** A: Check the official site for current pricing. The free tier is suitable for prototyping and small projects. ## Sources - https://github.com/instantdb/instant - https://www.instantdb.com/docs --- Source: https://tokrepo.com/en/workflows/asset-dc5da43d Author: AI Open Source