Registry /
storage / react-native-session-storage
Install & Compatibility
Where this runs
No compatibility data collected yet for this library.
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
default
✓ import SessionStorage from 'react-native-session-storage'
✗ import { SessionStorage } from 'react-native-session-storage'
Default import only; named import does not exist.
type
✓ import type { SessionStorage } from 'react-native-session-storage'
✗ import { SessionStorage } from 'react-native-session-storage'
If you need the type, use import type to avoid bundling issues.
require
✓ const SessionStorage = require('react-native-session-storage').default
✗ const SessionStorage = require('react-native-session-storage')
CommonJS require pattern must access .default property.
Demonstrates basic CRUD operations (setItem, getItem, removeItem, clear, length) and advanced multiGet/getAllItems using default import.
import SessionStorage from 'react-native-session-storage';
// Store a value
SessionStorage.setItem('user', { name: 'Alice' });
// Retrieve a value
const user = SessionStorage.getItem('user');
console.log(user); // { name: 'Alice' }
// Get length
console.log(SessionStorage.length); // 1
// Remove a specific item
SessionStorage.removeItem('user');
// Clear all
SessionStorage.clear();
// Advanced: multiGet
SessionStorage.setItem('a', 1);
SessionStorage.setItem('b', 2);
const multi = SessionStorage.multiGet(['a', 'b']);
console.log(multi); // { a: 1, b: 2 }
// Get all items
SessionStorage.setItem('x', { foo: 'bar' });
const all = SessionStorage.getAllItems();
console.log(all); // { x: { foo: 'bar' } }
Errors
Common errors & fixes
undefined is not an object (evaluating 'SessionStorage.setItem')
Using default import without .default in CommonJS environment (e.g., Jest).
fixUse `const SessionStorage = require('react-native-session-storage').default;` 'SessionStorage' is not exported from 'react-native-session-storage'
Attempting named import when only default export exists.
fixUse `import SessionStorage from 'react-native-session-storage'`
Cannot read property 'clear' of undefined
The module was not initialized correctly; maybe using a non-standard bundler.
fixEnsure the module is properly linked in React Native (if using bare workflow) or use Expo SDK 49+.
Audit
Dependencies
react-nativerequiredRequires React Native runtime for native platform implementation