swr

Implement SWR data fetching, caching, and revalidation in React applications.

Updated Aug 27, 2026
One-click install
npx skills add https://github.com/Witroch4/witdev-skills --skill swr-witroch4
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: swr
Source: https://github.com/Witroch4/witdev-skills/tree/main/swr
Command: npx skills add https://github.com/Witroch4/witdev-skills --skill swr-witroch4

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill addresses the complexities of client-side data fetching in React applications, providing a robust solution for managing loading states, errors, and data synchronization.

Core Features & Use Cases

  • Stale-While-Revalidate: Delivers cached data instantly while revalidating in the background for a seamless user experience.
  • Automatic Revalidation: Keeps data fresh on mount, window focus, and network reconnection.
  • Request Deduplication: Ensures only one request is made for identical data needs across your application.
  • Use Case: Displaying a list of user profiles that updates automatically when the user focuses the browser window, without manual refresh actions.

Quick Start

Use the swr skill to fetch user data from the '/api/users/123' endpoint.

Frequently Asked Questions about swr

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

FAQPage Schema
How does stale-while-revalidate work for React data fetching?

Stale-while-revalidate data fetching delivers cached data instantly while revalidating in the background, ensuring a seamless user experience. This mechanism keeps your React application responsive while retrieving the latest server state.

How do I configure global data fetching and custom fetchers in React?

You configure global data fetching by defining a custom fetcher and applying global configuration in your React application. This centralizes API requests and standardizes data synchronization across multiple hooks.

What is the best way to handle pagination and error handling in React hooks?

The best way to handle pagination and error handling in React hooks is using dedicated mutation patterns and revalidation strategies. This optimizes client-side data management and simplifies complex error boundaries.

Does SWR automatically revalidate data on window focus and network reconnection?

Yes, SWR automatically revalidates data on mount, window focus, and network reconnection. This automatic revalidation strategy keeps cached data fresh without requiring manual refresh actions.

Can I prevent duplicate API requests for identical data needs across my React application?

Yes, SWR prevents duplicate API requests through request deduplication, ensuring only one request is made for identical data needs across your React application. This optimizes performance and reduces unnecessary server load.