Add a new hook variant (e.g., useSWRFoo)
Suggested by the saved analysis. Some step paths were not captured or refer to generated or vendor files; only observed source files are linked.
- Export hook and types from root package.json exports map
Understand vercel/swr's source layout and find a starting point for your task using the saved repository evidence.
Detailed import-graph metrics were not captured for this report.
Files at 9ed1240a4cf7 · descriptions are AI-written.
Suggested by the saved analysis. Some step paths were not captured or refer to generated or vendor files; only observed source files are linked.
Suggested by the saved analysis. Verify the proposed change against these source files.
Suggested by the saved analysis. Verify the proposed change against these source files.
Start at the entry points declared by the captured manifest, then trace their implementation and tests.
Use a nearby test as a pattern. Read the root manifest or contribution guide for the correct test command. These suggestions use file names, not verified execution paths.
Inspect the relevant configuration and the commands it runs before changing the workflow. These suggestions use file names, not verified execution paths.
File paths come from a snapshot of up to 500 captured paths; an omitted file may still exist.
Primary hook entry point implementing the core SWR data-fetching logic with cache, revalidation, and subscription management.
Implements the stale-while-revalidate cache storage and lookup mechanism that underpins all data fetching.
Defines default configuration options and merging logic for global and per-hook SWR settings.
Internal exports barrel for utilities, types, and helpers used across hook implementations.
Pagination-aware hook variant extending core SWR for infinite scroll and paginated data patterns.
Mutation hook for handling data mutations with optimistic updates and revalidation strategies.
Root package manifest defining build targets, exports, pnpm workspace configuration, and React version requirements.
React Hooks API
Provides composable state and lifecycle management for function components without class boilerplate.
Stale-While-Revalidate (RFC 5861)
Balances perceived performance (immediate stale data) with data freshness (background revalidation).
pnpm monorepo workspace
Enables independent sub-packages (swr/infinite, swr/mutation, swr/subscription) while sharing core code.
TypeScript with SWC transpilation
Provides type safety and faster build times compared to Babel; supports React Server Components via conditional exports.
Build-time
Runtime
Global cache state shared across all component instances
Eliminates data duplication and enables automatic deduplication of identical requests.
Cache is not isolated per component; context pollution possible if multiple SWR providers co-exist.
Stale-while-revalidate over always-fresh data
Reduces perceived latency by serving cached data immediately while fetching in background.
Users may see stale data momentarily; applications requiring absolute freshness need custom revalidation logic.
Separate hook variants (useSWR, useSWRInfinite, useSWRMutation) over monolithic hook
Reduces bundle size for applications using only specific variants; simpler API per use case.
More imports to manage; code duplication across variants; integration complexity if mixing variants.
This repo is in good health with CI, tests, and active maintenance.
How maintainable the code looks — from complexity, code issues, test presence, file size, and hotspot load. It grades the shape of the code, not defect risk, and doesn't replace review.
Provider: GitHub Actions
140 test files detected
Stack: Jest/Vitest
Where: test/e2e · test/e2e/site/app/partially-hydrate · test/e2e/site/app
140 test files / 133 source files. This is a file-count ratio, not real line coverage — set up Codecov for authoritative numbers.
No Dependabot / Renovate / Snyk / Trivy / CodeQL config found. Enable Dependabot or Renovate.
Files edited often AND hard to reason about. Churn = recent commit frequency, Complexity = branches and nesting, Risk = both combined. These are the highest-leverage targets for refactoring or testing.
Files that change often and are complex tend to accumulate more bugs
Pattern-matches from the file structure and dependencies — useful as hypotheses, but not grounded in actual source. For real findings see Code Scanning above.
All hook instances share a single Map-based cache; no per-instance or per-tenant isolation; potential data leakage in multi-tenant scenarios.
src/_internal/utils/global-state.ts
Revalidation errors after mutation success are caught silently; consumers may not detect partial failures.
src/mutation/index.ts
Hook does not validate that fetcher is callable or returns a Promise; runtime errors only occur on invocation.
src/index/use-swr.ts
Cache keys never expire or are evicted; memory usage grows indefinitely as new keys are fetched.
src/_internal/utils/cache.ts
Speculation from file structure, not profiling data. Validate against real metrics before acting on these.
Cache lookup and update operations are synchronous and unoptimized; linear scan on large caches.
src/_internal/utils/cache.ts
Cache key serialization may be expensive for deeply nested or large objects; no memoization.
src/_internal/utils/serialize.ts
Event broadcasting to all subscribers on a key is O(n) subscribers; no batch updates.
src/index/use-swr.ts
Static analysis on sampled source files (up to 15 files).