Installations
npm install solid-swr-store
Developer Guide
Typescript
Yes
Module System
ESM
Min. Node Version
>=10
Node Version
19.6.0
NPM Version
lerna/6.5.1/node@v19.6.0+x64 (win32)
Score
99.1
Supply Chain
98.4
Quality
75.7
Maintenance
100
Vulnerability
100
License
Releases
Contributors
Languages
TypeScript (95.54%)
JavaScript (4.46%)
Developer
lxsmnsyc
Download Statistics
Total Downloads
7,730,814
Last Day
14,633
Last Week
60,694
Last Month
270,518
Last Year
6,325,460
GitHub Statistics
7 Stars
134 Commits
3 Watching
1 Branches
1 Contributors
Bundle Size
809.00 B
Minified
437.00 B
Minified + Gzipped
Package Meta Information
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
Publised On
21 Feb 2023
Total Downloads
Cumulative downloads
Total Downloads
7,730,814
Last day
-14.3%
14,633
Compared to previous day
Last week
-8.8%
60,694
Compared to previous week
Last month
28.7%
270,518
Compared to previous month
Last year
350.5%
6,325,460
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
solid-swr-store
SolidJS bindings for
swr-store
Install
1npm install --save swr-store solid-swr-store
1yarn add swr-store solid-swr-store
Usage
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}
API
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 noinitialData
is provided, defaults to store'soptions.initialData
.shouldRevalidate
: Iftrue
, goes through the revalidation process when reading through the cache. Defaults totrue
.
useSWRStoreSuspenseless(store, args, options)
Has the same API as useSWRStore
except that it doesn't suspend the reading component.
License
MIT © lxsmnsyc
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
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
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'main'
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
25 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-wf5p-g6vw-rhxx
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-ghr5-ch3p-vcr6
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-rc47-6667-2j5j
- Warn: Project is vulnerable to: GHSA-78xj-cgh5-2h22
- Warn: Project is vulnerable to: GHSA-2p57-rm9w-gvfp
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-mwcw-c2x4-8c55
- Warn: Project is vulnerable to: GHSA-7fh5-64p2-3v2j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-f5x3-32g6-xq36
- Warn: Project is vulnerable to: GHSA-353f-5xf4-qw67
- Warn: Project is vulnerable to: GHSA-c24v-8rfc-w8vw
- Warn: Project is vulnerable to: GHSA-8jhw-289h-jh2g
- Warn: Project is vulnerable to: GHSA-64vr-g452-qvp3
- Warn: Project is vulnerable to: GHSA-9cwx-2883-4wfx
- Warn: Project is vulnerable to: GHSA-vg6x-rcgg-rjx6
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
Score
1.7
/10
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