Gathering detailed insights and metrics for preact-swr-store
Gathering detailed insights and metrics for preact-swr-store
npm install preact-swr-store
Typescript
Module System
Min. Node Version
Node Version
NPM Version
70
Supply Chain
88.9
Quality
76
Maintenance
100
Vulnerability
100
License
TypeScript (95.54%)
JavaScript (4.46%)
Total Downloads
2,362
Last Day
3
Last Week
11
Last Month
31
Last Year
259
7 Stars
134 Commits
3 Watching
1 Branches
1 Contributors
Minified
Minified + Gzipped
Latest Version
0.10.6
Package Id
preact-swr-store@0.10.6
Unpacked Size
22.56 kB
Size
6.14 kB
File Count
15
NPM Version
lerna/6.5.1/node@v19.6.0+x64 (win32)
Node Version
19.6.0
Publised On
21 Feb 2023
Cumulative downloads
Total Downloads
Last day
-84.2%
3
Compared to previous day
Last week
-42.1%
11
Compared to previous week
Last month
72.2%
31
Compared to previous month
Last year
-56.4%
259
Compared to previous year
2
Preact bindings for
swr-store
1npm install --save swr-store preact-swr-store
1yarn add swr-store preact-swr-store
1import { Suspense } from 'preact'; 2import { createSWRStore } from 'swr-store'; 3import { useSWRStore, SWRStoreRoot } from 'preact-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 suspense: true, 26 }); 27 28 return <img src={data.message} alt={data.message} />; 29} 30 31function Trigger(): JSX.Element { 32 return ( 33 <button 34 type="button" 35 onClick={() => { 36 dogAPI.trigger(['shiba']); 37 }} 38 > 39 Trigger 40 </button> 41 ); 42} 43 44export default function App(): JSX.Element { 45 return ( 46 <SWRStoreRoot> 47 <Trigger /> 48 <div> 49 <Suspense fallback={<h1>Loading...</h1>}> 50 <DogImage /> 51 </Suspense> 52 </div> 53 </SWRStoreRoot> 54 ); 55}
<SWRStoreRoot>
Must be located at the root of the app/tree.
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:
suspense
: When true
, suspends the component when receiving the result, if the result status is 'pending'
until the result resolves,where useSWRStore
returns the resolved data. Otherwise, useSWRStore
returns the result. Defaults to false
.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
.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
25 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-01-27
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