Gathering detailed insights and metrics for solid-swr-store
Gathering detailed insights and metrics for solid-swr-store
Gathering detailed insights and metrics for solid-swr-store
Gathering detailed insights and metrics for solid-swr-store
Reactive, data-fetching stores with stale-while-revalidate strategy
npm install solid-swr-store
Typescript
Module System
Min. Node Version
Node Version
NPM Version
98.9
Supply Chain
97.9
Quality
75.7
Maintenance
100
Vulnerability
100
License
TypeScript (95.54%)
JavaScript (4.46%)
Total Downloads
8,840,573
Last Day
3,552
Last Week
50,394
Last Month
217,429
Last Year
4,434,674
MIT License
7 Stars
134 Commits
2 Watchers
1 Branches
1 Contributors
Updated on Dec 14, 2022
Minified
Minified + Gzipped
Latest Version
0.10.7
Package Id
solid-swr-store@0.10.7
Unpacked Size
17.11 kB
Size
5.11 kB
File Count
13
NPM Version
lerna/6.5.1/node@v19.6.0+x64 (win32)
Node Version
19.6.0
Published on
Feb 21, 2023
Cumulative downloads
Total Downloads
Last Day
19.8%
3,552
Compared to previous day
Last Week
-7.6%
50,394
Compared to previous week
Last Month
-19.4%
217,429
Compared to previous month
Last Year
0.7%
4,434,674
Compared to previous year
SolidJS bindings for
swr-store
1npm install --save swr-store solid-swr-store
1yarn add swr-store solid-swr-store
1import { Suspense } from 'solid-js'; 2import { createSWRStore } from 'swr-store'; 3import { useSWRStore, useSWRStoreSuspenselesss } from 'solid-swr-store'; 4 5const API = 'https://dog.ceo/api/breed/'; 6const API_SUFFIX = '/images/random'; 7 8interface APIResult { 9 message: string; 10 status: string; 11} 12 13const dogAPI = createSWRStore<APIResult, [string]>({ 14 key: (breed: string) => breed, 15 get: async (breed: string) => { 16 const response = await fetch(`${API}${breed}${API_SUFFIX}`); 17 return (await response.json()) as APIResult; 18 }, 19 revalidateOnFocus: true, 20 revalidateOnNetwork: true, 21}); 22 23function DogImage(): JSX.Element { 24 const data = useSWRStore(dogAPI, ['shiba']); 25 26 return <img src={data().message} alt={data().message} />; 27} 28 29function DogImageSuspenseless(): JSX.Element { 30 const data = useSWRStoreSuspenseless(dogAPI, ['shiba']); 31 32 return () => { 33 const current = data(); 34 35 if (current.status === 'pending') { 36 return <h1>Loading...</h1>; 37 } 38 if (current.status === 'failure') { 39 return <h1>Something went wrong.</h1> 40 } 41 return <img src={current.data.message} alt={current.data.message} />; 42 }; 43} 44 45function Trigger(): JSX.Element { 46 return ( 47 <button 48 type="button" 49 onClick={() => { 50 dogAPI.trigger(['shiba']); 51 }} 52 > 53 Trigger 54 </button> 55 ); 56} 57 58export default function App(): JSX.Element { 59 return ( 60 <> 61 <Trigger /> 62 <div> 63 <Suspense fallback={<h1>Loading...</h1>}> 64 <DogImage /> 65 </Suspense> 66 <DogImageSuspenseless /> 67 </div> 68 </> 69 ); 70}
useSWRStore(store, args, options)
Subscribes to an SWR store, passing args
, which are received by the corresponding store for data-fetching and cache updates.
options
has the following properties:
initialData
: Allows lazy hydration when reading the store. If the store does not have cache, initialData
hydrates the cache and attempts a revalidation. If no initialData
is provided, defaults to store's options.initialData
.shouldRevalidate
: If true
, goes through the revalidation process when reading through the cache. Defaults to true
.useSWRStoreSuspenseless(store, args, options)
Has the same API as useSWRStore
except that it doesn't suspend the reading component.
MIT © lxsmnsyc
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
security policy file not detected
Details
Reason
39 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More