Gathering detailed insights and metrics for mobx-url-sync
Gathering detailed insights and metrics for mobx-url-sync
Gathering detailed insights and metrics for mobx-url-sync
Gathering detailed insights and metrics for mobx-url-sync
npm install mobx-url-sync
Typescript
Module System
Node Version
NPM Version
69.9
Supply Chain
99.3
Quality
79.8
Maintenance
100
Vulnerability
100
License
TypeScript (100%)
Built with Next.js • Fully responsive • SEO optimized • Open source ready
Total Downloads
532
Last Day
3
Last Week
4
Last Month
34
Last Year
532
MIT License
13 Commits
1 Watchers
1 Branches
1 Contributors
Updated on May 20, 2025
Latest Version
1.0.5
Package Id
mobx-url-sync@1.0.5
Unpacked Size
11.82 kB
Size
4.24 kB
File Count
5
NPM Version
10.8.2
Node Version
20.19.0
Published on
May 20, 2025
Cumulative downloads
Total Downloads
Last Day
0%
3
Compared to previous day
Last Week
0%
4
Compared to previous week
Last Month
-79%
34
Compared to previous month
Last Year
0%
532
Compared to previous year
1
3
Synchronizes MobX observables with URL query parameters.
intercept
to monitor and sync property changes.Install via npm:
1npm install mobx-url-sync
This examples shows a MobX store holding a counter property which is automatically synchronized with the URL query parameter counter
.
1// counterStore.ts 2import { makeAutoObservable } from 'mobx' 3import { MobxUrlSync } from 'mobx-url-sync' 4 5// Define allowed query parameter(s) (here, only "counter" is allowed) 6type QueryParams = 'counter' 7 8// Initialize MobxUrlSync (no custom serializers needed for numbers) 9const mobxUrlSync = new MobxUrlSync<QueryParams>() 10 11export class CounterStore { 12 counter: number = 0 13 14 constructor() { 15 makeAutoObservable(this) 16 // Register the counter property to sync with the "counter" query parameter. 17 mobxUrlSync.registerField(this, 'counter', 'counter') 18 } 19 20 increment() { 21 this.counter++ 22 } 23 24 decrement() { 25 this.counter-- 26 } 27} 28 29export const counterStore = new CounterStore()
After calling counterStore.increment()
the URL will change to ?counter=1
.
MobxUrlSync<QueryParameter extends string>
1new MobxUrlSync(defaultSerializers?: Serializers, options?: { throttleDelay?: number })
registerField
1registerField<TStore, K extends keyof TStore>( 2 store: TStore, 3 property: K, 4 queryParam: QueryParameter, 5 config?: { 6 defaultValue?: TStore[K]; 7 serialize?: (value: TStore[K]) => string; 8 deserialize?: (value: string) => TStore[K]; 9 } 10): void
On Registration:
The field is added, and its current value is loaded from the URL if available.
On Changes:
When the property changes, the URL is updated (debounced). If the new value matches the default or is null/undefined, the query parameter is removed.
No vulnerabilities found.