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:| Browser | Version | IndexedDB Support |
|---|---|---|
| Chrome | 24+ | ✅ Full support |
| Firefox | 16+ | ✅ Full support |
| Safari | 10+ | ✅ Full support |
| Edge | All versions | ✅ Full support |
| Opera | 15+ | ✅ Full support |
| iOS Safari | 10+ | ✅ Full support |
| Android | 4.4+ | ✅ Full 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)
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
| Browser | Quota Type | Limit |
|---|---|---|
| Chrome | Temporary | Up to 60% of total disk |
| Firefox | Temporary | Up to 50% of free disk |
| Safari | Temporary | ~1 GB |
| Edge | Temporary | Up to 60% of total disk |
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
- Open browser DevTools (F12)
- Go to Application tab
- Expand IndexedDB in sidebar
- Find your database (e.g., “myapp”)
- 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:- File protocol: Load your page via http:// or https://, not file://
- Private browsing: Some browsers disable IndexedDB in private mode
- Browser too old: Update to a modern browser
”QuotaExceededError”
You’ve exceeded the storage quota:Connection Errors
If you see transaction errors:Best Practices
- Set a meaningful database name: Use
fileoption to name your database - Request persistent storage: For important apps, request persistence
- Monitor quota usage: Check available storage regularly
- Handle offline gracefully: IndexedDB works offline
- Clear old data: Implement data retention policies
- Test in private mode: Ensure fallback works
- 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