{"id":49488,"library":"sync-storage","title":"SyncStorage","description":"SyncStorage wraps React Native's asynchronous AsyncStorage to provide a synchronous API for reading and writing key-value pairs. Version 0.4.2 (stable, less frequent releases) loads all stored data into memory on init, enabling synchronous get/set/remove operations thereafter. It supports any value type (via JSON serialization) and returns promises for post-verification. Unlike raw AsyncStorage which requires async/await, SyncStorage simplifies simple data access in synchronous contexts but requires careful memory management for large datasets.","status":"active","version":"0.4.2","language":"javascript","source_language":"en","source_url":"https://github.com/raphaelpor/SyncStorage","tags":["javascript","AsyncStorage","React","Native","SyncStorage","Storage"],"install":[{"cmd":"npm install sync-storage","lang":"bash","label":"npm"},{"cmd":"yarn add sync-storage","lang":"bash","label":"yarn"},{"cmd":"pnpm add sync-storage","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"peer dependency required by React Native","package":"react","optional":false},{"reason":"peer dependency that must be installed for accessing AsyncStorage","package":"react-native","version":">=0.61","optional":false}],"imports":[{"note":"The module exports a default singleton object. No named exports.","wrong":"import { SyncStorage } from 'sync-storage'","symbol":"default","correct":"import SyncStorage from 'sync-storage'"},{"note":"init must be called before using get/set/remove; it populates in-memory cache from AsyncStorage.","wrong":"SyncStorage.init() (without await, returns a Promise)","symbol":"init","correct":"await SyncStorage.init()"},{"note":"Returns array of keys synchronously after init; no longer returns a promise.","wrong":"await SyncStorage.getAllKeys()","symbol":"getAllKeys","correct":"SyncStorage.getAllKeys()"},{"note":"CommonJS supported but ESM recommended for tree shaking.","wrong":"const { SyncStorage } = require('sync-storage')","symbol":"require","correct":"const SyncStorage = require('sync-storage')"}],"quickstart":{"code":"import SyncStorage from 'sync-storage';\n\nasync function main() {\n  await SyncStorage.init(); // must await before using sync methods\n  SyncStorage.set('foo', { bar: [1, 2, 3] });\n  const value = SyncStorage.get('foo');\n  console.log(value); // { bar: [1, 2, 3] }\n\n  SyncStorage.set('counter', 42);\n  console.log(SyncStorage.get('counter')); // 42\n\n  SyncStorage.remove('counter');\n  console.log(SyncStorage.get('counter')); // undefined\n\n  SyncStorage.set('a', 1);\n  SyncStorage.set('b', 2);\n  console.log(SyncStorage.getAllKeys()); // ['a', 'b']\n}\nmain().catch(console.error);","lang":"javascript","description":"Demonstrates initializing SyncStorage, then using synchronous get/set/remove/getAllKeys with various data types."},"warnings":[{"fix":"Call await SyncStorage.init() at app startup before any SyncStorage usage.","message":"init() must be called and awaited before any synchronous operations; otherwise get returns undefined.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Avoid storing large amounts of data with SyncStorage; use AsyncStorage directly for large data.","message":"SyncStorage keeps the entire AsyncStorage in memory; large datasets can cause memory issues on devices.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Use await SyncStorage.remove(key) or .then() to ensure removal completes.","message":"remove() returns a Promise but is often mistaken as synchronous; not awaiting it may lead to race conditions.","severity":"deprecated","affected_versions":">=0.1.0"},{"fix":"Call init() exactly once during app lifecycle.","message":"Calling init() multiple times may cause duplicate data but no error; it re-initializes the in-memory store.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"search_vec":"'0.4.2':23 'access':66 'api':13 'async/await':61 'asynchron':7 'asyncstorag':8,58,79 'care':72 'context':69 'data':31,65 'dataset':77 'enabl':36 'frequent':26 'get/set/remove':38 'init':35 'javascript':78 'json':47 'key':19 'key-valu':18 'larg':76 'less':25 'load':28 'manag':74 'memori':33,73 'nativ':5,81 'oper':39 'pair':21 'post':54 'post-verif':53 'promis':51 'provid':10 'raw':57 'react':4,80 'read':15 'releas':27 'requir':60,71 'return':50 'serial':48 'simpl':64 'simplifi':63 'stabl':24 'storag':83 'store':30 'support':42 'synchron':12,37,68 'syncstorag':1,2,62,82 'thereaft':40 'type':45 'unlik':56 'valu':20,44 'verif':55 'version':22 'via':46 'wrap':3 'write':17","created_at":"2026-06-07T17:02:01.757808+00:00","updated_at":"2026-06-07T17:02:01.757808+00:00","problems":[{"fix":"Ensure import SyncStorage from 'sync-storage'; is correct.","cause":"SyncStorage was imported incorrectly or not imported at all.","error":"TypeError: undefined is not an object (evaluating 'SyncStorage.get')"},{"fix":"Use import SyncStorage from 'sync-storage'; (no curly braces).","cause":"Using { SyncStorage } named import instead of default import.","error":"SyncStorage is not a function"},{"fix":"Install @react-native-async-storage/async-storage and link for React Native <0.60.","cause":"react-native AsyncStorage not installed or linked correctly.","error":"ReferenceError: Can't find variable: AsyncStorage"},{"fix":"Add await before SyncStorage.init().","cause":"init() not awaited before calling get/set/remove, so internal AsyncStorage key list is null.","error":"Possible Unhandled Promise Rejection: TypeError: null is not an object"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/raphaelpor/SyncStorage#readme","github":"https://github.com/raphaelpor/SyncStorage","docs":null,"changelog":null,"pypi":null,"npm":"sync-storage","openapi_spec":null,"status_page":null,"smithery":null,"categories":["storage"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}