Skip to content

Commit 890afed

Browse files
committed
chore: Swap READMEs
1 parent 81d5e25 commit 890afed

File tree

2 files changed

+55
-55
lines changed

2 files changed

+55
-55
lines changed

README.md

Lines changed: 26 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| **V3 Docs** | [V4 Beta Docs](./README_V4.md) |
1+
| **V4 Docs** | [old V3 Docs](./README_V3.md) |
22
|:---|:---|
33

44
<a href="https://margelo.io">
@@ -42,16 +42,13 @@
4242
* **Customizable storage location**
4343
* **High performance** because everything is **written in C++**
4444
* **~30x faster than AsyncStorage**
45-
* Uses [**JSI**](https://reactnative.dev/docs/the-new-architecture/landing-page#fast-javascriptnative-interfacing) and [**C++ TurboModules**](https://github.com/reactwg/react-native-new-architecture/blob/main/docs/turbo-modules-xplat.md) instead of the "old" Bridge
45+
* Uses [**JSI**](https://reactnative.dev/docs/the-new-architecture/landing-page#fast-javascriptnative-interfacing) and [**C++ NitroModules**](https://github.com/mrousavy/nitro) instead of the "old" Bridge
4646
* **iOS**, **Android** and **Web** support
4747
* Easy to use **React Hooks** API
4848

4949
> [!IMPORTANT]
50-
> - **You're looking at MMKV V3. If you want to upgrade to the beta, check out the [V4 docs here](./README_V4.md)**!
51-
> react-native-mmkv V3 is now a pure C++ TurboModule, and **requires the new architecture to be enabled**. (react-native 0.75+)
52-
> - If you want to use react-native-mmkv 3.x.x, you need to enable the new architecture in your app (see ["Enable the New Architecture for Apps"](https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md))
53-
> - For React-Native 0.74.x, use react-native-mmkv 3.0.1. For React-Native 0.75.x and higher, use react-native-mmkv 3.0.2 or higher.
54-
> - If you cannot use the new architecture yet, downgrade to react-native-mmkv 2.x.x for now.
50+
> - **You're looking at MMKV V4. If you're still on V3, check out the [V3 docs here](./README_V3.md)**!
51+
> - react-native-mmkv **V4** is now a [Nitro Module](https://nitro.margelo.com). See the [V4 Upgrade Guide](./docs/V4_UPGRADE_GUIDE.md) for more information.
5552
5653
## Benchmark
5754

@@ -72,14 +69,14 @@
7269
### React Native
7370

7471
```sh
75-
yarn add react-native-mmkv
72+
npm install react-native-mmkv react-native-nitro-modules
7673
cd ios && pod install
7774
```
7875

7976
### Expo
8077

8178
```sh
82-
npx expo install react-native-mmkv
79+
npx expo install react-native-mmkv react-native-nitro-modules
8380
npx expo prebuild
8481
```
8582

@@ -92,28 +89,28 @@ To create a new instance of the MMKV storage, use the `MMKV` constructor. It is
9289
#### Default
9390

9491
```js
95-
import { MMKV } from 'react-native-mmkv'
92+
import { createMMKV } from 'react-native-mmkv'
9693

97-
export const storage = new MMKV()
94+
export const storage = createMMKV()
9895
```
9996

10097
This creates a new storage instance using the default MMKV storage ID (`mmkv.default`).
10198

10299
#### App Groups or Extensions
103100

104-
If you want to share MMKV data between your app and other apps or app extensions in the same group, open `Info.plist` and create an `AppGroup` key with your app group's value. MMKV will then automatically store data inside the app group which can be read and written to from other apps or app extensions in the same group by making use of MMKV's multi processing mode.
101+
If you want to share MMKV data between your app and other apps or app extensions in the same group, open `Info.plist` and create an `AppGroupIdentifier` key with your app group's value. MMKV will then automatically store data inside the app group which can be read and written to from other apps or app extensions in the same group by making use of MMKV's multi processing mode.
105102
See [Configuring App Groups](https://developer.apple.com/documentation/xcode/configuring-app-groups).
106103

107104
#### Customize
108105

109106
```js
110-
import { MMKV, Mode } from 'react-native-mmkv'
107+
import { createMMKV } from 'react-native-mmkv'
111108

112-
export const storage = new MMKV({
109+
export const storage = createMMKV({
113110
id: `user-${userId}-storage`,
114111
path: `${USER_DIRECTORY}/storage`,
115112
encryptionKey: 'hunter2',
116-
mode: Mode.MULTI_PROCESS,
113+
mode: 'multi-process',
117114
readOnly: false
118115
})
119116
```
@@ -125,7 +122,7 @@ The following values can be configured:
125122
* `id`: The MMKV instance's ID. If you want to use multiple instances, use different IDs. For example, you can separate the global app's storage and a logged-in user's storage. (required if `path` or `encryptionKey` fields are specified, otherwise defaults to: `'mmkv.default'`)
126123
* `path`: The MMKV instance's root path. By default, MMKV stores file inside `$(Documents)/mmkv/`. You can customize MMKV's root directory on MMKV initialization (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#customize-location) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#customize-location))
127124
* `encryptionKey`: The MMKV instance's encryption/decryption key. By default, MMKV stores all key-values in plain text on file, relying on iOS's/Android's sandbox to make sure the file is encrypted. Should you worry about information leaking, you can choose to encrypt MMKV. (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#encryption) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#encryption))
128-
* `mode`: The MMKV's process behaviour - when set to `MULTI_PROCESS`, the MMKV instance will assume data can be changed from the outside (e.g. App Clips, Extensions or App Groups).
125+
* `mode`: The MMKV's process behaviour - when set to `multi-process`, the MMKV instance will assume data can be changed from the outside (e.g. App Clips, Extensions or App Groups).
129126
* `readOnly`: Whether this MMKV instance should be in read-only mode. This is typically more efficient and avoids unwanted writes to the data if not needed. Any call to `set(..)` will throw.
130127

131128
### Set
@@ -162,7 +159,7 @@ const hasUsername = storage.contains('user.name')
162159
const keys = storage.getAllKeys() // ['user.name', 'user.age', 'is-mmkv-fast-asf']
163160

164161
// delete a specific key + value
165-
storage.delete('user.name')
162+
const wasRemoved = storage.remove('user.name')
166163

167164
// delete all keys
168165
storage.clearAll()
@@ -221,21 +218,21 @@ if (size >= 4096) {
221218

222219
## Testing with Jest or Vitest
223220

224-
A mocked MMKV instance is automatically used when testing with Jest or Vitest, so you will be able to use `new MMKV()` as per normal in your tests. Refer to [package/example/test/MMKV.test.ts](package/example/test/MMKV.test.ts) for an example using Jest.
221+
A mocked MMKV instance is automatically used when testing with Jest or Vitest, so you will be able to use `createMMKV()` as per normal in your tests. Refer to [example/__tests__/MMKV.test.ts](example/__tests__/MMKV.test.ts) for an example using Jest.
225222

226223
## Documentation
227224

228-
* [Hooks](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/HOOKS.md)
229-
* [Value-change Listeners](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/LISTENERS.md)
230-
* [Migrate from AsyncStorage](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/MIGRATE_FROM_ASYNC_STORAGE.md)
231-
* [Using MMKV with redux-persist](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_REDUX.md)
232-
* [Using MMKV with recoil](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_RECOIL.md)
233-
* [Using MMKV with mobx-persist-storage](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_MOBX.md)
234-
* [Using MMKV with mobx-persist](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_MOBXPERSIST.md)
235-
* [Using MMKV with zustand persist-middleware](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_ZUSTAND_PERSIST_MIDDLEWARE.md)
236-
* [Using MMKV with jotai](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_JOTAI.md)
237-
* [Using MMKV with react-query](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_REACT_QUERY.md)
238-
* [Using MMKV with Tinybase](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_TINYBASE.md)
225+
* [Hooks](./docs/HOOKS.md)
226+
* [Value-change Listeners](./docs/LISTENERS.md)
227+
* [Migrate from AsyncStorage](./docs/MIGRATE_FROM_ASYNC_STORAGE.md)
228+
* [Using MMKV with redux-persist](./docs/WRAPPER_REDUX.md)
229+
* [Using MMKV with recoil](./docs/WRAPPER_RECOIL.md)
230+
* [Using MMKV with mobx-persist-storage](./docs/WRAPPER_MOBX.md)
231+
* [Using MMKV with mobx-persist](./docs/WRAPPER_MOBXPERSIST.md)
232+
* [Using MMKV with zustand persist-middleware](./docs/WRAPPER_ZUSTAND_PERSIST_MIDDLEWARE.md)
233+
* [Using MMKV with jotai](./docs/WRAPPER_JOTAI.md)
234+
* [Using MMKV with react-query](./docs/WRAPPER_REACT_QUERY.md)
235+
* [Using MMKV with Tinybase](./docs/WRAPPER_TINYBASE.md)
239236
* [How is this library different from **react-native-mmkv-storage**?](https://github.com/mrousavy/react-native-mmkv/issues/100#issuecomment-886477361)
240237

241238
## LocalStorage and In-Memory Storage (Web)

README_V4.md renamed to README_V3.md

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
| [V3 Docs](./README.md) | **V4 Beta Docs** |
1+
| [V4 Docs](./README.md) | **old V3 Docs** |
22
|:---|:---|
33

44
<a href="https://margelo.io">
@@ -42,13 +42,16 @@
4242
* **Customizable storage location**
4343
* **High performance** because everything is **written in C++**
4444
* **~30x faster than AsyncStorage**
45-
* Uses [**JSI**](https://reactnative.dev/docs/the-new-architecture/landing-page#fast-javascriptnative-interfacing) and [**C++ NitroModules**](https://github.com/mrousavy/nitro) instead of the "old" Bridge
45+
* Uses [**JSI**](https://reactnative.dev/docs/the-new-architecture/landing-page#fast-javascriptnative-interfacing) and [**C++ TurboModules**](https://github.com/reactwg/react-native-new-architecture/blob/main/docs/turbo-modules-xplat.md) instead of the "old" Bridge
4646
* **iOS**, **Android** and **Web** support
4747
* Easy to use **React Hooks** API
4848

4949
> [!IMPORTANT]
50-
> - **You're looking at MMKV V4. If you're still on V3, check out the [V3 docs here](./README.md)**!
51-
> - react-native-mmkv **V4** is now a [Nitro Module](https://nitro.margelo.com). See the [V4 Upgrade Guide](./docs/V4_UPGRADE_GUIDE.md) for more information.
50+
> - **You're looking at MMKV V3. If you want to upgrade to the beta, check out the [V4 docs here](./README.md)**!
51+
> react-native-mmkv V3 is now a pure C++ TurboModule, and **requires the new architecture to be enabled**. (react-native 0.75+)
52+
> - If you want to use react-native-mmkv 3.x.x, you need to enable the new architecture in your app (see ["Enable the New Architecture for Apps"](https://github.com/reactwg/react-native-new-architecture/blob/main/docs/enable-apps.md))
53+
> - For React-Native 0.74.x, use react-native-mmkv 3.0.1. For React-Native 0.75.x and higher, use react-native-mmkv 3.0.2 or higher.
54+
> - If you cannot use the new architecture yet, downgrade to react-native-mmkv 2.x.x for now.
5255
5356
## Benchmark
5457

@@ -69,14 +72,14 @@
6972
### React Native
7073

7174
```sh
72-
npm install react-native-mmkv react-native-nitro-modules
75+
yarn add react-native-mmkv
7376
cd ios && pod install
7477
```
7578

7679
### Expo
7780

7881
```sh
79-
npx expo install react-native-mmkv react-native-nitro-modules
82+
npx expo install react-native-mmkv
8083
npx expo prebuild
8184
```
8285

@@ -89,28 +92,28 @@ To create a new instance of the MMKV storage, use the `MMKV` constructor. It is
8992
#### Default
9093

9194
```js
92-
import { createMMKV } from 'react-native-mmkv'
95+
import { MMKV } from 'react-native-mmkv'
9396

94-
export const storage = createMMKV()
97+
export const storage = new MMKV()
9598
```
9699

97100
This creates a new storage instance using the default MMKV storage ID (`mmkv.default`).
98101

99102
#### App Groups or Extensions
100103

101-
If you want to share MMKV data between your app and other apps or app extensions in the same group, open `Info.plist` and create an `AppGroupIdentifier` key with your app group's value. MMKV will then automatically store data inside the app group which can be read and written to from other apps or app extensions in the same group by making use of MMKV's multi processing mode.
104+
If you want to share MMKV data between your app and other apps or app extensions in the same group, open `Info.plist` and create an `AppGroup` key with your app group's value. MMKV will then automatically store data inside the app group which can be read and written to from other apps or app extensions in the same group by making use of MMKV's multi processing mode.
102105
See [Configuring App Groups](https://developer.apple.com/documentation/xcode/configuring-app-groups).
103106

104107
#### Customize
105108

106109
```js
107-
import { createMMKV } from 'react-native-mmkv'
110+
import { MMKV, Mode } from 'react-native-mmkv'
108111

109-
export const storage = createMMKV({
112+
export const storage = new MMKV({
110113
id: `user-${userId}-storage`,
111114
path: `${USER_DIRECTORY}/storage`,
112115
encryptionKey: 'hunter2',
113-
mode: 'multi-process',
116+
mode: Mode.MULTI_PROCESS,
114117
readOnly: false
115118
})
116119
```
@@ -122,7 +125,7 @@ The following values can be configured:
122125
* `id`: The MMKV instance's ID. If you want to use multiple instances, use different IDs. For example, you can separate the global app's storage and a logged-in user's storage. (required if `path` or `encryptionKey` fields are specified, otherwise defaults to: `'mmkv.default'`)
123126
* `path`: The MMKV instance's root path. By default, MMKV stores file inside `$(Documents)/mmkv/`. You can customize MMKV's root directory on MMKV initialization (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#customize-location) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#customize-location))
124127
* `encryptionKey`: The MMKV instance's encryption/decryption key. By default, MMKV stores all key-values in plain text on file, relying on iOS's/Android's sandbox to make sure the file is encrypted. Should you worry about information leaking, you can choose to encrypt MMKV. (documentation: [iOS](https://github.com/Tencent/MMKV/wiki/iOS_advance#encryption) / [Android](https://github.com/Tencent/MMKV/wiki/android_advance#encryption))
125-
* `mode`: The MMKV's process behaviour - when set to `multi-process`, the MMKV instance will assume data can be changed from the outside (e.g. App Clips, Extensions or App Groups).
128+
* `mode`: The MMKV's process behaviour - when set to `MULTI_PROCESS`, the MMKV instance will assume data can be changed from the outside (e.g. App Clips, Extensions or App Groups).
126129
* `readOnly`: Whether this MMKV instance should be in read-only mode. This is typically more efficient and avoids unwanted writes to the data if not needed. Any call to `set(..)` will throw.
127130

128131
### Set
@@ -159,7 +162,7 @@ const hasUsername = storage.contains('user.name')
159162
const keys = storage.getAllKeys() // ['user.name', 'user.age', 'is-mmkv-fast-asf']
160163

161164
// delete a specific key + value
162-
const wasRemoved = storage.remove('user.name')
165+
storage.delete('user.name')
163166

164167
// delete all keys
165168
storage.clearAll()
@@ -218,21 +221,21 @@ if (size >= 4096) {
218221

219222
## Testing with Jest or Vitest
220223

221-
A mocked MMKV instance is automatically used when testing with Jest or Vitest, so you will be able to use `createMMKV()` as per normal in your tests. Refer to [example/__tests__/MMKV.test.ts](example/__tests__/MMKV.test.ts) for an example using Jest.
224+
A mocked MMKV instance is automatically used when testing with Jest or Vitest, so you will be able to use `new MMKV()` as per normal in your tests. Refer to [package/example/test/MMKV.test.ts](package/example/test/MMKV.test.ts) for an example using Jest.
222225

223226
## Documentation
224227

225-
* [Hooks](./docs/HOOKS.md)
226-
* [Value-change Listeners](./docs/LISTENERS.md)
227-
* [Migrate from AsyncStorage](./docs/MIGRATE_FROM_ASYNC_STORAGE.md)
228-
* [Using MMKV with redux-persist](./docs/WRAPPER_REDUX.md)
229-
* [Using MMKV with recoil](./docs/WRAPPER_RECOIL.md)
230-
* [Using MMKV with mobx-persist-storage](./docs/WRAPPER_MOBX.md)
231-
* [Using MMKV with mobx-persist](./docs/WRAPPER_MOBXPERSIST.md)
232-
* [Using MMKV with zustand persist-middleware](./docs/WRAPPER_ZUSTAND_PERSIST_MIDDLEWARE.md)
233-
* [Using MMKV with jotai](./docs/WRAPPER_JOTAI.md)
234-
* [Using MMKV with react-query](./docs/WRAPPER_REACT_QUERY.md)
235-
* [Using MMKV with Tinybase](./docs/WRAPPER_TINYBASE.md)
228+
* [Hooks](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/HOOKS.md)
229+
* [Value-change Listeners](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/LISTENERS.md)
230+
* [Migrate from AsyncStorage](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/MIGRATE_FROM_ASYNC_STORAGE.md)
231+
* [Using MMKV with redux-persist](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_REDUX.md)
232+
* [Using MMKV with recoil](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_RECOIL.md)
233+
* [Using MMKV with mobx-persist-storage](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_MOBX.md)
234+
* [Using MMKV with mobx-persist](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_MOBXPERSIST.md)
235+
* [Using MMKV with zustand persist-middleware](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_ZUSTAND_PERSIST_MIDDLEWARE.md)
236+
* [Using MMKV with jotai](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_JOTAI.md)
237+
* [Using MMKV with react-query](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_REACT_QUERY.md)
238+
* [Using MMKV with Tinybase](https://github.com/mrousavy/react-native-mmkv/blob/v3/docs/WRAPPER_TINYBASE.md)
236239
* [How is this library different from **react-native-mmkv-storage**?](https://github.com/mrousavy/react-native-mmkv/issues/100#issuecomment-886477361)
237240

238241
## LocalStorage and In-Memory Storage (Web)

0 commit comments

Comments
 (0)