swr

Fetch React data with stale-while-revalidate caching and custom fetchers.

246|42|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/vercel-labs/vercel-plugin --skill swr-vercel-labs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swr
Source: https://github.com/vercel-labs/vercel-plugin/tree/main/skills/swr
Command: npx skills add https://github.com/vercel-labs/vercel-plugin --skill swr-vercel-labs

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill simplifies and optimizes data fetching in React applications by providing robust caching, revalidation, and mutation capabilities out-of-the-box, reducing boilerplate and improving performance.

Core Features & Use Cases

  • Stale-While-Revalidate Caching: Serves cached data instantly while revalidating in the background.
  • Automatic Deduplication: Prevents multiple identical requests.
  • Real-time Data: Supports real-time data sources via useSWRSubscription.
  • Use Case: When building a dashboard that displays frequently updated data, use SWR to ensure the UI remains responsive by showing cached data immediately and updating it seamlessly as new data arrives.

Quick Start

Use the swr skill to fetch data from the '/api/user' endpoint using a provided fetcher function.

Frequently Asked Questions about swr

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I optimize React data fetching with stale-while-revalidate caching?

React data fetching with stale-while-revalidate caching instantly serves cached data while revalidating in the background, ensuring a responsive UI. This hook-based approach reduces boilerplate and improves performance.

What is the best way to handle client-side data fetching and automatic request deduplication in React?

Client-side data fetching in React benefits from automatic deduplication to prevent multiple identical API requests. Using a hook-based library streamlines this process while handling caching and revalidation out-of-the-box.

Can I implement optimistic UI and pagination for a React dashboard using SWR?

You can implement optimistic UI, pagination, and infinite loading for React dashboards using SWR. It handles mutations seamlessly, ensuring the UI remains responsive by showing cached data immediately during updates.

Does the SWR hook support real-time data sources and custom fetcher functions?

SWR supports real-time data sources via the useSWRSubscription hook and integrates with native fetch or custom fetcher functions for API requests. This enables real-time data updates without complex boilerplate.

When should I not use stale-while-revalidate hooks for data fetching?

You should avoid stale-while-revalidate hooks when your application requires strictly synchronous data fetching without background updates, as this strategy inherently serves cached data first before revalidating.