swr
Skill by openai
Guides React apps through SWR v2, the Vercel data-fetching library. It covers caching, revalidation, mutations, optimistic UI, pagination and infinite loading for developers building client-side data fetching.
Install swr
Built from the published package, never by AI.
git clone --depth 1 https://github.com/openai/plugins /tmp/plugins && mkdir -p ~/.claude/skills && cp -r /tmp/plugins/plugins/vercel/skills/swr ~/.claude/skills/swrRun in your terminal. Claude Code loads skills from ~/.claude/skills automatically.
git clone --depth 1 https://github.com/openai/plugins /tmp/plugins && mkdir -p ~/.gemini/antigravity-cli/skills && cp -r /tmp/plugins/plugins/vercel/skills/swr ~/.gemini/antigravity-cli/skills/swrAntigravity CLI loads skills from ~/.gemini/antigravity-cli/skills, or .agents/skills for one project.
Skills can run scripts on your machine. Some need an API key: check the README.
About
This skill gives an AI assistant expert guidance on SWR v2, the React Hooks library for data fetching by Vercel. SWR uses the stale-while-revalidate strategy: it serves cached data first, then revalidates in the background. The guidance covers the useSWR, useSWRMutation, useSWRInfinite and useSWRSubscription hooks, plus global configuration with SWRConfig.
The skill also explains revalidation options such as focus, reconnect and polling, optimistic updates with rollback, conditional fetching with null keys, and error retry behavior. It is aimed at developers building React apps that need client-side data fetching, caching, mutations, pagination or infinite loading.
Written from the project's SKILL.md and checked against it.
What it can do
- useSWRFetches and caches data by key, returning data, error, isLoading, isValidating and mutate.
- useSWRMutationRuns remote mutations with a trigger function and an isMutating flag.
- useSWRInfiniteHandles pagination and infinite loading with page keys, size and setSize.
- SWRConfigSets global defaults such as the fetcher, focus revalidation and deduping interval.
- Revalidation optionsControls revalidation on focus, reconnect, mount if stale and polling intervals.
- Optimistic updatesShows optimistic data during mutations with optional rollback on error and cache population.
- Conditional fetchingSkips requests by passing a null or falsy key.
- Error retryCustomizes retry behavior on errors through the onErrorRetry option.
- useSWRSubscriptionSubscribes to real-time sources such as WebSockets or SSE, with shared subscriptions per key.
What you need
- A React app
- Installation of the swr package via npm, pnpm, yarn or bun
Try asking
- Use SWR to fetch and cache the user profile from /api/user in my React app
- Add an optimistic update to my SWR mutation for updating a user name
- Build an infinite loading list with useSWRInfinite for /api/items
Good to know
- Hooks must not be called conditionally; use conditional keys (null) instead.
Security check
ANo download-and-run commands, hidden instructions or signs of sending keys out were found.
Checked automatically: plugins/vercel/skills/swr/SKILL.md. This looks for known risky patterns and is not a full audit. How grades work
Inside the skill
-
SKILL.md6 KB -
agents/openai.yaml90 B
Alternatives to swr
All alternatives →Runs a 7-stage workflow for auditing, cleaning up and reviewing GitHub repositories, plus competitor analysis. Written for developers who want a repo checked for secrets, junk files and documentation gaps.
Teaches an AI assistant to build, debug and explain Gradio web UIs and ML demos in Python. It covers the core API, components, event listeners, layouts and the MCP server option. Aimed at Python developers who work with Gradio.
Recommends menus, buttons, toolbars and disclosure controls for Apple platforms using Human Interface Guidelines conventions. Built for developers and designers making iOS, iPadOS, macOS or visionOS interfaces. Checks existing project design context before asking questions.
Creates production-ready FastAPI project structures with async patterns, dependency injection, and error handling. It is for developers starting new FastAPI applications or backend API projects.
Analyzes Android apps to find user workflows to expose as AppFunctions, so AI agents and system shortcuts can run them without opening the app UI. Generates Kotlin code and refines KDoc for Android developers.
Creates, edits, validates and runs Agent QA tests, suites and hooks through MCP or CLI. It keeps canonical IDs and schema contracts intact, for developers and QA teams using Agent QA.
Compare with openclaw-github-repo-commander, gradio or hig-components-menus
swr: common questions
What is SWR used for?
The source describes SWR as a React Hooks library for data fetching by Vercel. It implements the stale-while-revalidate strategy, serving cached data first and revalidating in the background.
Does SWR retry failed requests?
Yes. The source says SWR retries on error by default with exponential backoff, and the retry behavior can be customized with onErrorRetry.
How do I share one subscription between components?
According to the source, multiple components using the same key in useSWRSubscription share a single subscription.
How do I install swr?
Run the command above to copy the skill into ~/.claude/skills/. Claude Code picks it up automatically.
Is swr free?
The code is public, but no licence file was found, so check the repository before commercial use.
Is swr safe to use?
It scores 87 of 100. Grades: maintenance A, licence F, quality A. Security check: grade A, no risky patterns found in the files checked. Review the code before you install. How grades work.
What are alternatives to swr?
Similar skills: openclaw-github-repo-commander, gradio, hig-components-menus, fastapi-templates.
