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
> Zustand middleware to easily persist and sync Zustand state between tabs / windows / iframes (Same Origin)
5
+
> Zustand middleware to easily persist and sync Zustand state between tabs/windows/iframes (Same Origin)
6
6
7
-
> Motivation: Recently I got caught up in several issues working with persist middleware and syncing tabs with Zustand. This is a simple light weight middleware to persist and instantly share state between tabs or windows
7
+
> Motivation: Recently I got caught up in several issues working with the persist middleware and syncing tabs with Zustand. This is a simple lightweight middleware to persist and instantly share state between tabs or windows
8
8
9
-
- ✅ 🐙 (642 Bytes gZiped) ~ 0.5 kB size cross-tab state sharing + persistence for zustand
9
+
- ✅ 🐙 ~ 1 kB size cross-tab state sharing + persistence for zustand
10
10
- ✅ Full TypeScript Support
11
-
- ✅ solid reliability in 1 writing and n reading tab-scenarios (with changing writing tab)
12
-
- ✅ Fire and forget approach of always using the latest state. Perfect for singleuser systems
11
+
- ✅ solid reliability in 1 writing and n reading tabscenarios (with changing writing tab)
12
+
- ✅ Fire and forget approach of always using the latest state. Perfect for single-user systems
13
13
- ✅ Share state between multiple browsing contexts
14
-
- ✅ Additional control over which fields to persist-and-sync and which to ignore
14
+
- ✅ Additional control over which fields to `persist-and-sync` and which to ignore
15
15
- ✅ Optimized for performance using memoization and closures.
16
16
17
17
## Install
18
18
19
19
```bash
20
20
$ pnpm add persist-and-sync
21
-
# or
21
+
```
22
+
23
+
**or**
24
+
25
+
```bash
22
26
$ npm install persist-and-sync
23
-
# or
27
+
```
28
+
29
+
**or**
30
+
31
+
```bash
24
32
$ yarn add persist-and-sync
25
33
```
26
34
27
35
## Usage
28
36
29
-
Simply add the middleware while creating the store and the rest will be taken care.
37
+
Add the middleware while creating the store and the rest will be taken care.
@@ -114,15 +122,15 @@ For more details about regExp check out - [JS RegExp](https://www.w3schools.com/
114
122
115
123
### Exact match
116
124
117
-
For exactly matching a parameter/field use `/^your-field-name$/`. `^` forces match from the first caracter and similarly, `$` forces match until last character.
125
+
For exactly matching a parameter/field use `/^your-field-name$/`. `^` forces match from the first caracter and similarly, `$` forces match until the last character.
118
126
119
127
### Ignore multiple fields with exact match
120
128
121
129
use `regExpToIgnore: /^(field1|field2|field3)$/`
122
130
123
-
### 🤩 Don't forger to start[this repo](https://github.com/mayank1513/persist-and-sync)!
131
+
### 🤩 Don't forget to star[this repo](https://github.com/mayank1513/persist-and-sync)!
124
132
125
-
Want hands-on course for getting started with Turborepo? Check out [React and Next.js with TypeScript](https://mayank-chaudhari.vercel.app/courses/react-and-next-js-with-typescript) and [The Game of Chess with Next.js, React and TypeScrypt](https://www.udemy.com/course/game-of-chess-with-nextjs-react-and-typescrypt/?referralCode=851A28F10B254A8523FE)
133
+
Want a hands-on course for getting started with Turborepo? Check out [React and Next.js with TypeScript](https://mayank-chaudhari.vercel.app/courses/react-and-next-js-with-typescript) and [The Game of Chess with Next.js, React and TypeScrypt](https://www.udemy.com/course/game-of-chess-with-nextjs-react-and-typescrypt/?referralCode=851A28F10B254A8523FE)
0 commit comments