{"name":"swr","version":"2.2.2","keywords":["swr","react","hooks","request","cache","fetch"],"license":"MIT","_id":"swr@2.2.2","maintainers":[{"name":"gdborton","email":"gdborton@gmail.com"},{"name":"quietshu","email":"g@shud.in"},{"name":"huozhi","email":"inbox@huozhi.im"},{"name":"matt.straka","email":"matt.j.straka@gmail.com"},{"name":"nick.tracey","email":"nick.tracey@vercel.com"},{"name":"zeit-bot","email":"team@zeit.co"},{"name":"vercel-release-bot","email":"infra+release@vercel.com"}],"homepage":"https://swr.vercel.app","bugs":{"url":"https://github.com/vercel/swr/issues"},"dist":{"shasum":"abcb1f9c97e10527789884169d58b878472d4c98","tarball":"http://registry-npm.ywwl.com/swr/download/swr-2.2.2.tgz","fileCount":42,"integrity":"sha512-CbR41AoMD4TQBQw9ic3GTXspgfM9Y8Mdhb5Ob4uIKXhWqnRLItwA5fpGvB7SmSw3+zEjb0PdhiEumtUvYoQ+bQ==","signatures":[{"sig":"MEQCIGO6pJmx/W7mIvlweKY77RAW+vv+VojAseLaaZmTQVlOAiAOz7fJyd1tzZV8mxNq5EkYPW+TRC1YNNNBo5lnNjP5nw==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/swr@2.2.2","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"unpackedSize":300793,"size":70513,"noattachment":false,"key":"/swr/-/swr-2.2.2.tgz"},"main":"./core/dist/index.js","types":"./core/dist/index.d.ts","module":"./core/dist/index.esm.js","exports":{".":{"import":"./core/dist/index.mjs","module":"./core/dist/index.esm.js","require":"./core/dist/index.js","react-server":"./core/dist/react-server.mjs"},"./infinite":{"import":"./infinite/dist/index.mjs","module":"./infinite/dist/index.esm.js","require":"./infinite/dist/index.js","react-server":"./infinite/dist/react-server.mjs"},"./mutation":{"import":"./mutation/dist/index.mjs","module":"./mutation/dist/index.esm.js","require":"./mutation/dist/index.js"},"./_internal":{"import":"./_internal/dist/index.mjs","module":"./_internal/dist/index.esm.js","require":"./_internal/dist/index.js","react-server":"./_internal/dist/react-server.mjs"},"./immutable":{"import":"./immutable/dist/index.mjs","module":"./immutable/dist/index.esm.js","require":"./immutable/dist/index.js"},"./package.json":"./package.json","./subscription":{"import":"./subscription/dist/index.mjs","module":"./subscription/dist/index.esm.js","require":"./subscription/dist/index.js"}},"gitHead":"4d20bff6759d4478380963654a560a1cf9ae7be1","scripts":{"attw":"attw --pack","lint":"eslint . --ext .ts,.tsx --cache","test":"jest","build":"pnpm build-package _internal && pnpm build-package core && pnpm build-package infinite && pnpm build-package immutable && pnpm build-package mutation && pnpm build-package subscription","clean":"pnpm -r run clean && rimraf playwright-report test-result","watch":"pnpm -r run watch","format":"prettier --write ./**/*.{ts,tsx}","prepare":"husky install","coverage":"jest --coverage","lint:fix":"pnpm lint --fix","test:e2e":"playwright test","build:e2e":"pnpm next build e2e/site","csb:build":"pnpm build","test:build":"jest --config jest.config.build.js","csb:install":"corepack enable && corepack pnpm i","test-typing":"tsc --noEmit -p test/type/tsconfig.json && tsc --noEmit -p test/tsconfig.json","types:check":"pnpm -r run types:check","publish-beta":"pnpm publish --tag beta","build-package":"bunchee --cwd","prepublishOnly":"pnpm clean && pnpm build","run-all-checks":"pnpm types:check && pnpm lint && pnpm test-typing"},"_npmUser":{"name":"vercel-release-bot","email":"infra+release@vercel.com"},"prettier":{"semi":false,"useTabs":false,"tabWidth":2,"arrowParens":"avoid","singleQuote":true,"trailingComma":"none"},"repository":{"url":"git+https://github.com/vercel/swr.git","type":"git"},"_npmVersion":"9.6.7","description":"React Hooks library for remote data fetching","directories":{},"lint-staged":{"*.{ts,tsx}":["eslint --fix --cache","prettier --write"]},"_nodeVersion":"18.17.1","dependencies":{"client-only":"^0.0.1","use-sync-external-store":"^1.2.0"},"typesVersions":{"*":{"infinite":["./infinite/dist/index.d.ts"],"mutation":["./mutation/dist/index.d.ts"],"immutable":["./immutable/dist/index.d.ts"],"subscription":["./subscription/dist/index.d.ts"]}},"_hasShrinkwrap":false,"packageManager":"pnpm@8.4.0","devDependencies":{"swr":"workspace:*","jest":"29.5.0","next":"^13.4.4","husky":"8.0.3","react":"^18.2.0","eslint":"8.42.0","rimraf":"5.0.1","semver":"^7.5.1","bunchee":"3.6.0","prettier":"2.8.8","@swc/core":"^1.3.62","@swc/jest":"0.2.26","react-dom":"^18.2.0","typescript":"5.1.3","@types/jest":"^29.5.2","@types/node":"^20.2.5","lint-staged":"13.2.2","@types/react":"^18.2.8","@playwright/test":"^1.34.3","eslint-plugin-react":"7.32.2","react-error-boundary":"^4.0.9","@arethetypeswrong/cli":"^0.7.0","@testing-library/react":"^14.0.0","@type-challenges/utils":"0.1.1","eslint-config-prettier":"8.8.0","eslint-plugin-jest-dom":"5.0.1","jest-environment-jsdom":"29.5.0","@testing-library/jest-dom":"^5.16.5","@typescript-eslint/parser":"5.59.8","eslint-plugin-react-hooks":"4.6.0","eslint-plugin-testing-library":"5.11.0","@types/use-sync-external-store":"^0.0.3","@typescript-eslint/eslint-plugin":"5.59.8"},"peerDependencies":{"react":"^16.11.0 || ^17.0.0 || ^18.0.0"},"_npmOperationalInternal":{"tmp":"tmp/swr_2.2.2_1693139768474_0.13958395748686936","host":"s3://npm-registry-packages"},"readme":"[![SWR](https://assets.vercel.com/image/upload/v1572289618/swr/banner.png)](https://swr.vercel.app)\n\n<p align=\"center\">\n  <a aria-label=\"Vercel logo\" href=\"https://vercel.com\">\n    <img src=\"https://badgen.net/badge/icon/Made%20by%20Vercel?icon=zeit&label&color=black&labelColor=black\">\n  </a>\n  <br/>\n  <a aria-label=\"NPM version\" href=\"https://www.npmjs.com/package/swr\">\n    <img alt=\"\" src=\"https://badgen.net/npm/v/swr\">\n  </a>\n  <a aria-label=\"Package size\" href=\"https://bundlephobia.com/result?p=swr\">\n    <img alt=\"\" src=\"https://badgen.net/bundlephobia/minzip/swr\">\n  </a>\n  <a aria-label=\"License\" href=\"https://github.com/vercel/swr/blob/main/LICENSE\">\n    <img alt=\"\" src=\"https://badgen.net/npm/license/swr\">\n  </a>\n</p>\n\n## Introduction\n\nSWR is a React Hooks library for data fetching.\n\nThe name “**SWR**” is derived from `stale-while-revalidate`, a cache invalidation strategy popularized by [HTTP RFC 5861](https://tools.ietf.org/html/rfc5861).\n**SWR** first returns the data from cache (stale), then sends the request (revalidate), and finally comes with the up-to-date data again.\n\nWith just one hook, you can significantly simplify the data fetching logic in your project. And it also covered in all aspects of speed, correctness, and stability to help you build better experiences:\n\n- **Fast**, **lightweight** and **reusable** data fetching\n- Transport and protocol agnostic\n- Built-in **cache** and request deduplication\n- **Real-time** experience\n- Revalidation on focus\n- Revalidation on network recovery\n- Polling\n- Pagination and scroll position recovery\n- SSR and SSG\n- Local mutation (Optimistic UI)\n- Built-in smart error retry\n- TypeScript\n- React Suspense\n- React Native\n\n...and a lot more.\n\nWith SWR, components will get **a stream of data updates constantly and automatically**. Thus, the UI will be always **fast** and **reactive**.\n\n---\n\n**View full documentation and examples on [swr.vercel.app](https://swr.vercel.app).**\n\n<br/>\n\n## Quick Start\n\n```js\nimport useSWR from 'swr'\n\nfunction Profile() {\n  const { data, error, isLoading } = useSWR('/api/user', fetcher)\n\n  if (error) return <div>failed to load</div>\n  if (isLoading) return <div>loading...</div>\n  return <div>hello {data.name}!</div>\n}\n```\n\nIn this example, the React Hook `useSWR` accepts a `key` and a `fetcher` function.\nThe `key` is a unique identifier of the request, normally the URL of the API. And the `fetcher` accepts\n`key` as its parameter and returns the data asynchronously.\n\n`useSWR` also returns 3 values: `data`, `isLoading` and `error`. When the request (fetcher) is not yet finished,\n`data` will be `undefined` and `isLoading` will be `true`. When we get a response, it sets `data` and `error` based on the result\nof `fetcher`, `isLoading` to false and rerenders the component.\n\nNote that `fetcher` can be any asynchronous function, you can use your favourite data-fetching\nlibrary to handle that part.\n\n---\n\n**View full documentation and examples on [swr.vercel.app](https://swr.vercel.app).**\n\n<br/>\n\n## Authors\n\nThis library is created by the team behind [Next.js](https://nextjs.org), with contributions from our community:\n\n- Shu Ding ([@shuding\\_](https://x.com/shuding_)) - [Vercel](https://vercel.com)\n- Jiachi Liu ([@huozhi](https://x.com/huozhi)) - [Vercel](https://vercel.com)\n- Guillermo Rauch ([@rauchg](https://x.com/rauchg)) - [Vercel](https://vercel.com)\n- Joe Haddad ([@timer150](https://x.com/timer150)) - [Vercel](https://vercel.com)\n- Paco Coursey ([@pacocoursey](https://x.com/pacocoursey)) - [Vercel](https://vercel.com)\n\n[Contributors](https://github.com/vercel/swr/graphs/contributors)\n\nThanks to Ryan Chen for providing the awesome `swr` npm package name!\n\n<br/>\n\n## License\n\nThe MIT License.\n","publish_time":1693139768659,"_cnpm_publish_time":1693139768659,"dist-tags":{"beta":"2.6.0-beta.0","latest":"2.5.1","rc":"2.0.0-rc.3"}}