6 ms·
Yet to explore but just reading few snippets ... is this good for offline first apps? If not, any others you recommend for that use-case? If yet, is this read
by santa_boy 1y ago
Yet to explore but just reading few snippets ... is this good for offline first apps?
If not, any others you recommend for that use-case?
If yet, is this ready enough for production use?
- adrai 1y agoHey, thanks for the great questions! Offline-first: That's a key distinction. The Vaultrice SDK is currently designed for "online-first" and "offline-sometimes" use cases. Its main strength is real-time, consistent synchronization that relies on an active connection. Proper offline-first support with automatic conflict resolution is on our roadmap, as we have a backlog item for it ;-) However, you can easily achieve a robust offline capability in your own code today by using localStorage as a fallback. Here’s a simple wrapper pattern (not tested, just for illustration) that reads from Vaultrice when online and falls back to a local cache when offline: import { NonLocalStorage } from '@vaultrice/sdk'; // --- A simple offline-first wrapper --- function createOfflineStore(credentials, id) { const vaultriceStore = new NonLocalStorage(credentials, id); const localCacheKey = `vaultrice_cache_${id}`; // Helper to get local data const getLocal = () => JSON.parse(localStorage.getItem(localCacheKey) || '{}'); return { // SET: Write to both Vaultrice (if online) and localStorage async setItem(key, value) { // Always update the local cache immediately const localData = getLocal(); localData[key] = value; localStorage.setItem(localCacheKey, JSON.stringify(localData)); try { // Attempt to write to the cloud await vaultriceStore.setItem(key, value); } catch (error) { console.warn('Offline: Data saved locally.', error.message); } }, // GET: Try Vaultrice first, fallback to localStorage async getItem(key) { try { const item = await vaultriceStore.getItem(key); if (item) { // Optional: Update local cache with fresh data const localData = getLocal(); localData[key] = item.value; localStorage.setItem(localCacheKey, JSON.stringify(localData)); return item.value; } } catch (error) { console.warn('Offline: Reading from local cache.', error.message); } // Fallback to local cache return getLocal()[key]; } }; } Production Readiness: Yes, for its intended use case, Vaultrice is ready for production. We've put a lot of focus on a layered security model (from API key restrictions to E2EE) and built it on top of Cloudflare's infrastructure, which gives us a reliable and scalable foundation. Hope that helps clarify things! Appreciate you checking it out.
- adrai 1y agonow the SDK has some Offline APIs: https://www.vaultrice.com/blog/offline-apis https://www.vaultrice.com/blog/offline-apis