Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-mmkv

Package Overview
Dependencies
Maintainers
1
Versions
92
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-mmkv

The fastest key/value storage for React Native. ~30x faster than AsyncStorage! Works on Android, iOS and Web.

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
162K
decreased by-20.36%
Maintainers
1
Weekly downloads
 
Created

What is react-native-mmkv?

react-native-mmkv is a fast, small, and easy-to-use key-value storage library for React Native. It leverages Facebook's MMKV storage library to provide efficient and secure storage solutions for mobile applications.

What are react-native-mmkv's main functionalities?

Basic Key-Value Storage

This feature allows you to store and retrieve basic key-value pairs. The code sample demonstrates how to set and get a string value using MMKV.

import MMKVStorage from 'react-native-mmkv-storage';

const MMKV = new MMKVStorage.Loader().initialize();

// Set a value
MMKV.setString('username', 'john_doe');

// Get a value
const username = MMKV.getString('username');
console.log(username); // Output: john_doe

Object Storage

This feature allows you to store and retrieve objects. The code sample demonstrates how to set and get an object using MMKV.

import MMKVStorage from 'react-native-mmkv-storage';

const MMKV = new MMKVStorage.Loader().initialize();

const user = { name: 'John Doe', age: 30 };

// Set an object
MMKV.setMap('user', user);

// Get an object
const storedUser = MMKV.getMap('user');
console.log(storedUser); // Output: { name: 'John Doe', age: 30 }

Encryption

This feature allows you to store data securely using encryption. The code sample demonstrates how to set and get an encrypted string value using MMKV.

import MMKVStorage from 'react-native-mmkv-storage';

const MMKV = new MMKVStorage.Loader().withEncryption().initialize();

// Set a value
MMKV.setString('secret', 'my_secret_value');

// Get a value
const secret = MMKV.getString('secret');
console.log(secret); // Output: my_secret_value

Multi-Instance Support

This feature allows you to create multiple instances of storage, which can be useful for separating different types of data. The code sample demonstrates how to set and get values from different instances using MMKV.

import MMKVStorage from 'react-native-mmkv-storage';

const userStorage = new MMKVStorage.Loader().withInstanceID('user').initialize();
const settingsStorage = new MMKVStorage.Loader().withInstanceID('settings').initialize();

// Set values in different instances
userStorage.setString('username', 'john_doe');
settingsStorage.setBool('darkMode', true);

// Get values from different instances
const username = userStorage.getString('username');
const darkMode = settingsStorage.getBool('darkMode');
console.log(username); // Output: john_doe
console.log(darkMode); // Output: true

Other packages similar to react-native-mmkv

Keywords

FAQs

Package last updated on 22 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc