New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

swrv

Package Overview
Dependencies
Maintainers
2
Versions
67
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

swrv

swrv

  • 1.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
856K
increased by1.46%
Maintainers
2
Weekly downloads
 
Created

What is swrv?

swrv is a library for data fetching in Vue applications, providing a way to fetch, cache, and revalidate data at the component level. It is inspired by the SWR (stale-while-revalidate) strategy, which allows for efficient and user-friendly data fetching.

What are swrv's main functionalities?

Basic Data Fetching

This feature allows you to fetch data from an API endpoint and handle loading and error states. The `useSWRV` hook is used to fetch data and automatically revalidate it when necessary.

```javascript
import useSWRV from 'swrv';

export default {
  setup() {
    const { data, error } = useSWRV('/api/data', fetcher);
    return { data, error };
  }
};
```

Caching

swrv provides built-in caching mechanisms to store and retrieve data efficiently. You can customize the cache storage by passing a cache instance.

```javascript
import useSWRV from 'swrv';

export default {
  setup() {
    const { data, error } = useSWRV('/api/data', fetcher, { cache: new Map() });
    return { data, error };
  }
};
```

Revalidation

Revalidation allows you to refresh the data manually or automatically. The `mutate` function can be used to trigger a revalidation.

```javascript
import useSWRV from 'swrv';

export default {
  setup() {
    const { data, error, mutate } = useSWRV('/api/data', fetcher);
    return { data, error, mutate };
  }
};
```

Other packages similar to swrv

FAQs

Package last updated on 21 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc