You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+26-29Lines changed: 26 additions & 29 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
|**V3 Docs**|[V4 Beta Docs](./README_V4.md)|
1
+
|**V4 Docs**|[old V3 Docs](./README_V3.md)|
2
2
|:---|:---|
3
3
4
4
<ahref="https://margelo.io">
@@ -42,16 +42,13 @@
42
42
***Customizable storage location**
43
43
***High performance** because everything is **written in C++**
44
44
***~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
46
46
***iOS**, **Android** and **Web** support
47
47
* Easy to use **React Hooks** API
48
48
49
49
> [!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.
@@ -92,28 +89,28 @@ To create a new instance of the MMKV storage, use the `MMKV` constructor. It is
92
89
#### Default
93
90
94
91
```js
95
-
import { MMKV } from'react-native-mmkv'
92
+
import { createMMKV } from'react-native-mmkv'
96
93
97
-
exportconststorage=newMMKV()
94
+
exportconststorage=createMMKV()
98
95
```
99
96
100
97
This creates a new storage instance using the default MMKV storage ID (`mmkv.default`).
101
98
102
99
#### App Groups or Extensions
103
100
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.
105
102
See [Configuring App Groups](https://developer.apple.com/documentation/xcode/configuring-app-groups).
106
103
107
104
#### Customize
108
105
109
106
```js
110
-
import { MMKV, Mode } from'react-native-mmkv'
107
+
import { createMMKV } from'react-native-mmkv'
111
108
112
-
exportconststorage=newMMKV({
109
+
exportconststorage=createMMKV({
113
110
id:`user-${userId}-storage`,
114
111
path:`${USER_DIRECTORY}/storage`,
115
112
encryptionKey:'hunter2',
116
-
mode:Mode.MULTI_PROCESS,
113
+
mode:'multi-process',
117
114
readOnly:false
118
115
})
119
116
```
@@ -125,7 +122,7 @@ The following values can be configured:
125
122
*`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'`)
126
123
*`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))
127
124
*`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).
129
126
*`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.
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.
Copy file name to clipboardExpand all lines: README_V3.md
+29-26Lines changed: 29 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,4 +1,4 @@
1
-
|[V3 Docs](./README.md)|**V4 Beta Docs**|
1
+
|[V4 Docs](./README.md)|**old V3 Docs**|
2
2
|:---|:---|
3
3
4
4
<ahref="https://margelo.io">
@@ -42,13 +42,16 @@
42
42
***Customizable storage location**
43
43
***High performance** because everything is **written in C++**
44
44
***~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
46
46
***iOS**, **Android** and **Web** support
47
47
* Easy to use **React Hooks** API
48
48
49
49
> [!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.
@@ -89,28 +92,28 @@ To create a new instance of the MMKV storage, use the `MMKV` constructor. It is
89
92
#### Default
90
93
91
94
```js
92
-
import { createMMKV } from'react-native-mmkv'
95
+
import { MMKV } from'react-native-mmkv'
93
96
94
-
exportconststorage=createMMKV()
97
+
exportconststorage=newMMKV()
95
98
```
96
99
97
100
This creates a new storage instance using the default MMKV storage ID (`mmkv.default`).
98
101
99
102
#### App Groups or Extensions
100
103
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.
102
105
See [Configuring App Groups](https://developer.apple.com/documentation/xcode/configuring-app-groups).
103
106
104
107
#### Customize
105
108
106
109
```js
107
-
import { createMMKV } from'react-native-mmkv'
110
+
import { MMKV, Mode } from'react-native-mmkv'
108
111
109
-
exportconststorage=createMMKV({
112
+
exportconststorage=newMMKV({
110
113
id:`user-${userId}-storage`,
111
114
path:`${USER_DIRECTORY}/storage`,
112
115
encryptionKey:'hunter2',
113
-
mode:'multi-process',
116
+
mode:Mode.MULTI_PROCESS,
114
117
readOnly:false
115
118
})
116
119
```
@@ -122,7 +125,7 @@ The following values can be configured:
122
125
*`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'`)
123
126
*`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))
124
127
*`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).
126
129
*`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.
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.
222
225
223
226
## Documentation
224
227
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)
0 commit comments