{"schemaVersion":1,"id":"swr","name":"SWR","locale":"en","canonicalUrl":"https://base.akulich.dev/en/library/swr/","officialUrl":"https://github.com/vercel/swr","isCatalog":false,"description":"React data fetching hooks with caching and revalidation: they display current server data and request states in the interface.","tasks":["Add cached data fetching to a React screen","Connect the hook to the component's loading, error, and revalidation states"],"categoryIds":["frontend"],"subcategoryIds":["frontend.utilities","frontend.state"],"tags":["SWR","web","Development"],"aliases":["vercel/swr","swr","stale-while-revalidate"],"platforms":[],"stack":[],"compatibility":null,"pricing":"free","freeUsage":"Code and local use under MIT.","paidUsage":"Computing resources, self-hosting, and external services are paid for separately if used.","license":"MIT for the code; dependencies have separate licenses.","selectionGuide":{"purpose":"Add cached data fetching to a React screen","chooseWhen":["Add cached data fetching to a React screen","Connect the hook to the component's loading, error, and revalidation states"],"considerInstead":["When choosing for this topic, compare SWR with TanStack Query. A candidate to compare under the topic: State and client data, Web interface tools. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together.","When choosing for this topic, compare SWR with Immer. A candidate to compare under the topic: State and client data. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together."],"requirements":["Define stable keys, a fetcher, and separate loading/error states."],"limitations":["Costs and limits of free use: Computing resources, self-hosting, and external services are paid for separately if used.","Terms of use: MIT for the code; dependencies have separate licenses.","A cache does not replace server permissions or important data freshness checks. The fetcher may use a chosen network/API and its terms."],"faq":[{"question":"What can you use for free in SWR?","answer":"Code and local use under MIT."},{"question":"What additional costs might arise with SWR?","answer":"Computing resources, self-hosting, and external services are paid for separately if used."},{"question":"What terms of use matter for SWR?","answer":"MIT for the code; dependencies have separate licenses."},{"question":"How do you get started with SWR?","answer":"Define a data key and fetcher for the required API. Connect the hook to the component's loading, error, and revalidation states. Add real data and error handling; check the production build."},{"question":"What does SWR do with stale data, and what is a fetcher?","answer":"SWR first returns cached data, then revalidates the request and updates the result. useSWR accepts a key and asynchronous fetcher, returning data, error, and isLoading. Deduplication, focus/network recovery revalidation, polling, optimistic mutation, and SSR/SSG are supported; the fetcher chooses the transport."}],"related":[{"id":"tanstack-query","reason":"A candidate to compare under the topic: State and client data, Web interface tools. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together."},{"id":"immer","reason":"A candidate to compare under the topic: State and client data. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together."},{"id":"jotai","reason":"A candidate to compare under the topic: State and client data. This is an editorial connection by topic, not a confirmed alternative or a guarantee that the products work together."}],"sources":["https://github.com/vercel/swr","https://raw.githubusercontent.com/vercel/swr/HEAD/README.md","https://raw.githubusercontent.com/vercel/swr/HEAD/LICENSE","https://www.open-source-tools.com/"]},"selectionCheckedAt":null,"applicationGuide":{"goal":"Add cached data fetching to a React screen.","inputs":["Web application source code and the intended workflow.","The project's framework and runtime version."],"steps":["Define a data key and fetcher for the required API.","Connect the hook to the component's loading, error, and revalidation states.","Add real data and error handling; check the production build."],"checks":["The workflow works after a page refresh and with invalid data.","The bundle, server rendering, and supported browsers suit the project."]},"sources":["https://github.com/vercel/swr","https://raw.githubusercontent.com/vercel/swr/HEAD/README.md","https://raw.githubusercontent.com/vercel/swr/HEAD/LICENSE","https://www.open-source-tools.com/"],"checkedAt":"2026-10-06","reviewScope":"The purpose, current repository license, and separate terms for code, services, and models have been reviewed. The product was not run, and no security audit was performed.","relatedIds":["zustand","jotai","valtio","immer","tanstack-query"],"dataVersion":"cbbe7123b47a5ae80983","type":"Web framework / library","kind":"library","pricingNote":"Code and local use under MIT. Computing resources, self-hosting, and external services are paid for separately if used.","notes":null,"labeledSources":[{"url":"https://github.com/vercel/swr","label":"Official source"},{"url":"https://raw.githubusercontent.com/vercel/swr/HEAD/README.md","label":"Official source"},{"url":"https://raw.githubusercontent.com/vercel/swr/HEAD/LICENSE","label":"License"},{"url":"https://www.open-source-tools.com/","label":"Catalog / discovery source"}],"licenseGuides":[{"id":"mit","title":"MIT — permissive license","scope":null,"summary":"You can use, modify, distribute, and sell the code, including in a closed-source commercial product. When sharing copies or substantial portions of the code, retain the license text and copyright notice. You do not need to open-source your entire project; the author provides no warranties.","url":"https://opensource.org/license/mit"}],"entryIds":[],"composition":null}