Gathering detailed insights and metrics for @lucianojd/recoil-sync-next
Gathering detailed insights and metrics for @lucianojd/recoil-sync-next
Gathering detailed insights and metrics for @lucianojd/recoil-sync-next
Gathering detailed insights and metrics for @lucianojd/recoil-sync-next
npm install @lucianojd/recoil-sync-next
Typescript
Module System
TypeScript (100%)
Total Downloads
0
Last Day
0
Last Week
0
Last Month
0
Last Year
0
MIT License
59 Stars
1,039 Commits
8 Forks
13 Watchers
9 Branches
10 Contributors
Updated on Jul 10, 2025
Latest Version
0.0.3
Package Id
@lucianojd/recoil-sync-next@0.0.3
Unpacked Size
69.09 kB
Size
16.46 kB
File Count
87
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
7
32
Recoil Sync stores for Next.js
1npm install recoil recoil-sync recoil-sync-next 2# or 3yarn add recoil recoil-sync recoil-sync-next 4# or 5pnpm add recoil recoil-sync recoil-sync-next
This provides recoil-sync's URL Persistence functionality interfaced with next/router.
A version of <RecoilURLSyncJSON> that works with next/router to sync atoms with the browser URL using JSON encoding. This should be a child element of <RecoilRoot>.
1function RecoilURLSyncJSONNext(props: { 2 storeKey?: string | undefined 3 location: LocationOption 4 children: ReactNode 5}): ReactNode
storeKey
location
shallow
children
1import { RecoilURLSyncJSONNext } from 'recoil-sync-next' 2 3function MyApp({ Component, pageProps }: AppProps) { 4 return ( 5 <RecoilRoot> 6 <RecoilURLSyncJSONNext location={{ part: 'queryParams' }}> 7 <Component {...pageProps} /> 8 </RecoilURLSyncJSONNext> 9 </RecoilRoot> 10 ) 11}
A version of <RecoilURLSyncTransit> that works with next/router to sync atoms with the browser URL using Transit encoding. This should be a child element of <RecoilRoot>.
1function RecoilURLSyncTransitNext(props: { 2 storeKey?: string | undefined 3 location: LocationOption 4 handlers?: ReadonlyArray<TransitHandler<any, any>> 5 children: ReactNode 6}): ReactNode
storeKey
location
shallow
handlers
children
1import { RecoilURLSyncTransitNext } from 'recoil-sync-next' 2 3function MyApp({ Component, pageProps }: AppProps) { 4 return ( 5 <RecoilRoot> 6 <RecoilURLSyncTransitNext location={{ part: 'queryParams' }}> 7 <Component {...pageProps} /> 8 </RecoilURLSyncTransitNext> 9 </RecoilRoot> 10 ) 11}
Provides persistence of atoms to session storage synced with the position of the history entry.
It will save atoms to session storage when the history entry's position is moved.
When the user moves backward/forward on history entries (i.e. 'popstate'
event is fired),
the atoms saved with that position is restored.
To sync atoms with the position of the history entry using JSON encoding. This should be a child element of <RecoilRoot>.
1function RecoilHistorySyncJSONNext(props: { 2 storeKey?: string | undefined 3 children: ReactNode 4}): ReactNode
storeKey
children
1import { RecoilHistorySyncJSONNext } from 'recoil-sync-next' 2 3function MyApp({ Component, pageProps }: AppProps) { 4 return ( 5 <RecoilRoot> 6 <RecoilHistorySyncJSONNext> 7 <Component {...pageProps} /> 8 </RecoilHistorySyncJSONNext> 9 </RecoilRoot> 10 ) 11}
To sync atoms with the position of the history entry using Transit encoding. This should be a child element of <RecoilRoot>.
1function RecoilHistorySyncTransitNext(props: { 2 storeKey?: string | undefined 3 handlers?: ReadonlyArray<TransitHandler<any, any>> 4 children: ReactNode 5}): ReactNode
storeKey
handlers
children
1import { RecoilHistorySyncTransitNext } from 'recoil-sync-next' 2 3function MyApp({ Component, pageProps }: AppProps) { 4 return ( 5 <RecoilRoot> 6 <RecoilHistorySyncTransitNext> 7 <Component {...pageProps} /> 8 </RecoilHistorySyncTransitNext> 9 </RecoilRoot> 10 ) 11}
atom
, but initial value can be specified when using it.
Note: This is just a utility and does not depend on either Recoil Sync or Next.js.
1function initializableAtom<T extends SerializableParam>(options: { 2 key: string 3 effects?: 4 | ReadonlyArray<AtomEffect<T>> 5 | ((param: P) => ReadonlyArray<AtomEffect<T>>) 6 dangerouslyAllowMutability?: boolean 7}): (initialValue: T) => RecoilState<T>
See atom for more info.
A function which takes its initialValue
.
1import { initializableAtom } from 'recoil-sync-next' 2 3const countState = initializableAtom<number>({ 4 key: 'count', 5}) 6 7const MyComponent: React.FC = () => { 8 const [count, setCount] = useRecoilState(countState(100)) // count is initialized to 100 9 ... 10}
atomFamily
, but initial value can be specified individually when using it.
Note: This is just a utility and does not depend on either Recoil Sync or Next.js.
1function initializableAtomFamily< 2 T extends SerializableParam, 3 P extends SerializableParam 4>(options: { 5 key: string 6 effects?: 7 | ReadonlyArray<AtomEffect<T>> 8 | ((param: P) => ReadonlyArray<AtomEffect<T>>) 9 dangerouslyAllowMutability?: boolean 10}): (parameter: P, initialValue: T) => RecoilState<T>
See atomFamily for more info.
A function which takes parameter
that map to an atom, and its initialValue
.
1import { initializableAtomFamily } from 'recoil-sync-next' 2 3const countState = initializableAtomFamily<number, string>({ 4 key: 'count', 5}) 6 7const MyComponent: React.FC = () => { 8 const [count1, setCount1] = useRecoilState(countState('foo', 0)) // count1 is initialized to 0 9 const [count2, setCount2] = useRecoilState(countState('bar', 100)) // count2 is initialized to 100 10 ... 11}
No vulnerabilities found.
No security vulnerabilities found.