SWR llms.txt · AI Docs Browser · mdream

[llms.txt Tools](https://mdream.dev/llms-txt/swr/llms-txt)

# SWR llms.txt

Browse SWR documentation as markdown. Click any page in the sidebar to view it, or copy the full llms.txt for your AI tools.

swr.vercel.app/llms.txt

[Raw llms.txt](https://swr.vercel.app/llms.txt) [Raw llms-full.txt](https://swr.vercel.app/llms-full.txt)

Copy Markdown [](https://swr.vercel.app/llms.txt)

llms.txt

Parameters

(advanced usage)

(details)

Return Values

(details)

Options

(details)

(details)

(details)

(details)

(details)

(details)

(example)

(details)

(details)

stable-hash

(details)

Multiple Arguments

Passing Objects

Conditional

Dependent

Fetch

Axios

GraphQL

Status Code and Error Object

Error Retry

Global Error Report

Installation

Quick Start

Make It Reusable

Example

Nesting Configurations

Extra APIs

Usage

Examples

mutate

a filter function

useSWRMutation

mutate

Optimistic Updates

Rollback on Errors

Update Cache After Mutation

Avoid Race Conditions

Mutate Based on Current Data

Mutate Multiple Items

When to Use useSWR

useSWRInfinite

fetcher function

Top-Level Page Data

Programmatically Prefetch

Pre-fill Data

Pre-fetch in React Server Components (RSC)

Revalidate on Focus

Revalidate on Interval

Revalidate on Reconnect

Disable Automatic Revalidations

Revalidate on Mount

useSWRSubscription

Basic Usage

Generics

Middleware Types

App Router

Client Side Data Fetching

Pre-rendering with Default Data

Cache Provider

Create Cache Provider

Access Current Cache Provider

Experimental: Extend Cache Provider

Examples

https://chrome.google.com/webstore/detail/swr-devtools/liidbicegefhheghhjbomajjaehnjned

https://addons.mozilla.org/en-US/firefox/addon/swr-devtools/

Deduplication

Deep Comparison

Dependency Collection

Tree Shaking

Example

State Machine

Combining with isLoading and isValidating for better UX

Return previous data for better UX

Dependency Collection for performance

## What is SWR's llms.txt?

SWR publishes an `/llms.txt` file that provides AI systems with a structured index of its documentation. It follows the [llms.txt specification](https://llmstxt.org), organizing links to guides, API references, and tutorials under section headings so that LLMs like ChatGPT, Claude, and Gemini can quickly understand what SWR offers and where to find details.

Issues

Spec

61

Sections

19

Links

98.1 KB

Size

~25.1k

Tokens

Sections: Parameters · Return Values · Options · Multiple Arguments · Passing Objects · Conditional · and 55 more

## Add SWR Docs to Your AI Assistant

Select your tool to see how to add SWR's llms.txt as a documentation source.

Cursor

 Windsurf

 Claude Code

 ChatGPT

 Zed

 Copilot

1. 1

   Open any chat or composer panel
2. 2

   Type @Docs and select "Add new doc"
3. 3

   Paste the URL: https://swr.vercel.app/llms.txt
4. 4

   Wait for the green dot (indexing complete)
5. 5

   Reference @Docs in chat when asking about SWR

Cursor crawls the URL and indexes all subpages. Add a trailing slash to index child pages too.

## Spec Compliance 59 errors

## Frequently Asked Questions

Where is SWR's llms.txt file?

SWR publishes its llms.txt at https://swr.vercel.app/llms.txt. This file provides a structured, markdown-formatted index of SWR's documentation that AI systems can consume to understand the project's APIs, guides, and references.

How do I use SWR's llms.txt with AI coding assistants?

Copy the llms.txt content and paste it into your AI assistant (Cursor, Windsurf, Claude, ChatGPT) as context. This gives the AI an accurate map of SWR's documentation so it can provide better code suggestions and answers about SWR.

What does SWR's llms.txt contain?

SWR's llms.txt contains 61 sections and 19 documentation links in 98.1 KB (~25.1k tokens). Key sections include Parameters, Return Values, Options, Multiple Arguments, Passing Objects, Conditional.

How many tokens does SWR's llms.txt use?

The concise llms.txt index is approximately 25.1k tokens (98.1 KB). Most AI assistants can fit this within their context window. For the full expanded documentation, look for an llms-full.txt variant which embeds all content inline.

What is SWR?

React Hooks for Data Fetching. SWR's llms.txt file helps AI systems understand this by providing a structured overview of its documentation, making it easier for developers to get accurate AI-assisted help when working with SWR.

Can I generate an llms.txt for my own project?

Yes. Use the free llms.txt generator at mdream.dev/tools/llms-txt/generator to crawl your site and produce a spec-compliant llms.txt file. You can also validate existing files with the llms.txt validator.

## Browse More llms.txt Files

[Kysely The type-safe SQL query builder for TypeScript](https://mdream.dev/llms-txt/swr/llms-txt/kysely) [Zustand Bear necessities for state management in React](https://mdream.dev/llms-txt/swr/llms-txt/zustand) [unstorage Universal Storage Layer](https://mdream.dev/llms-txt/swr/llms-txt/unstorage) [Effect A powerful TypeScript library for complex programs](https://mdream.dev/llms-txt/swr/llms-txt/effect) [Wagmi React Hooks for Ethereum](https://mdream.dev/llms-txt/swr/llms-txt/wagmi) [Valibot The modular and type safe schema library](https://mdream.dev/llms-txt/swr/llms-txt/valibot) [Remotion Make videos programmatically with React](https://mdream.dev/llms-txt/swr/llms-txt/remotion) [Zod TypeScript-first schema validation](https://mdream.dev/llms-txt/swr/llms-txt/zod)

[View all 99 projects ](https://mdream.dev/llms-txt/swr/llms-txt)

## Related Tools

[<h3>llms.txt Generator</h3>Generate an llms.txt for your own project.](https://mdream.dev/llms-txt/swr/tools/llms-txt/generator) [<h3>llms.txt Validator</h3>Validate your llms.txt against the official spec.](https://mdream.dev/llms-txt/swr/tools/llms-txt/validator)

© 2026 [Harlan Wilton](https://github.com/harlan-zw) · [MIT](https://github.com/harlan-zw/mdream/blob/main/license)

[GitHub](https://github.com/harlan-zw/mdream) [Discord](https://discord.com/invite/275MBUBvgP)