Skip to main content

Rindexed Storage Adapter

Rindexed is GUN’s storage adapter for browser environments. It stores data in IndexedDB, the browser’s native database, with automatic fallback to in-memory storage when IndexedDB is unavailable.

Installation

Rindexed is included with GUN and automatically enabled in browser environments:

With Module Bundlers

With Node.js (for testing)

Configuration Options

Rindexed accepts the following configuration options:

Key Options

file (string)

Name of the IndexedDB database. This will appear in browser DevTools under Application > IndexedDB. Default: 'radata'

indexedDB (object)

Optional IndexedDB instance. Useful for testing or when using a custom IndexedDB implementation. Default: window.indexedDB

How Rindexed Works

IndexedDB Storage

Rindexed creates an IndexedDB database with a single object store:

Storage Structure

Data is organized as key-value pairs:

Automatic Fallback

If IndexedDB is unavailable (e.g., private browsing, file:// protocol), Rindexed automatically falls back to in-memory storage:

Connection Reset (WebKit Bug Workaround)

Rindexed automatically closes and reopens the IndexedDB connection every 15 seconds to work around a WebKit bug:

Storage Interface

Rindexed provides a standard storage interface:

Browser Compatibility

Rindexed works in all modern browsers with IndexedDB support:

Private Browsing Mode

In private/incognito mode, some browsers restrict IndexedDB:
  • Chrome/Edge: IndexedDB works normally
  • Firefox: IndexedDB works normally
  • Safari: IndexedDB may be disabled (fallback to memory)
Rindexed automatically detects this and uses in-memory storage.

Storage Quota

Browsers limit how much data you can store in IndexedDB:

Checking Available Quota

Requesting Persistent Storage

For critical applications, request persistent storage to prevent eviction:

Typical Quota Limits

Data Persistence

When Data Persists

IndexedDB data persists:
  • ✅ Across browser sessions
  • ✅ After browser restart
  • ✅ After system reboot
  • ✅ During offline use

When Data May Be Cleared

Browsers may clear IndexedDB data:
  • ⚠️ When disk space is low (temporary storage)
  • ⚠️ After extended periods of inactivity
  • ⚠️ When user clears browser data
  • ⚠️ In private browsing mode (after session)

Working with GUN

Basic Setup

Offline-First Applications

Progressive Web Apps (PWA)

Performance Optimization

Batching Writes

Rindexed batches operations automatically, but you can optimize further:

Limiting Data Size

Keep individual values small for better performance:

Monitoring Performance

Debugging

Inspecting Data in DevTools

  1. Open browser DevTools (F12)
  2. Go to Application tab
  3. Expand IndexedDB in sidebar
  4. Find your database (e.g., “myapp”)
  5. Expand object stores to view data

Reading Raw Data

Clearing Data

Troubleshooting

”Warning: No indexedDB exists to persist data to!”

This warning appears when IndexedDB is unavailable. Common causes:
  1. File protocol: Load your page via http:// or https://, not file://
  2. Private browsing: Some browsers disable IndexedDB in private mode
  3. Browser too old: Update to a modern browser

”QuotaExceededError”

You’ve exceeded the storage quota:

Connection Errors

If you see transaction errors:

Best Practices

  1. Set a meaningful database name: Use file option to name your database
  2. Request persistent storage: For important apps, request persistence
  3. Monitor quota usage: Check available storage regularly
  4. Handle offline gracefully: IndexedDB works offline
  5. Clear old data: Implement data retention policies
  6. Test in private mode: Ensure fallback works
  7. Use version numbers: Include version in database name for migrations

Next Steps

RADisk Adapter

File system storage for Node.js

S3 Adapter

Cloud storage with Amazon S3

Custom Adapters

Build your own storage adapter

Offline Apps

Build offline-first applications