RepositoryTypeScript
vercel

vercel/swr

React Hooks for Data Fetching

32.5kstars
1.4kforks
158issues
6views

Thành tựu nổi bật

Những danh hiệu mới nhất của dự án

1
TINIX TRENDING·Chủ đề: hooks

#1 Repository Của Tuần

1
TINIX TRENDING·Chủ đề: fetch

#1 Repository Của Tuần

1
TINIX TRENDING·Chủ đề: hook

#1 Repository Của Tuần

🚀 SWR: React Hooks fetch dữ liệu thông minh từ Vercel

Một hook đơn giản, cả thế giới cập nhật tự động.

SWR (Stale-while-revalidate) là thư viện React Hooks dùng cho việc fetch dữ liệu, được tạo bởi đội ngũ phát triển Next.js tại Vercel. Tên gọi xuất phát từ chiến lược bỗ sung cache stale-while-revalidate trong HTTP RFC 5861: trước tiên trả về dữ liệu từ cache (cũ), sau đó gửi yêu cầu cập nhật (revalidate), cuối cùng cập nhật UI với dữ liệu mới nhất.

✨ Điểm nổi bật

  • Fast, lightweight & reusable: Tối ưu tốc độ, kích thước nhỏ gọn, tái sử dụng dễ dàng.
  • Transport & protocol agnostic: Hỗ trợ mọi phương thức truyền tải và giao thức.
  • Built-in cache + deduplication: Tích hợp sẵn cache và loại bỏ các yêu cầu trùng lặp.
  • Real-time experience: Trải nghiệm cập nhật theo thời gian thực.
  • Revalidation on focus / network recovery: Tự động cập nhật khi người dùng quay lại tab hoặc kết nối mạng.
  • Polling, pagination, scroll recovery: Hỗ trợ polling, phân trang và khôi phục vị trí cuộn trang.
  • SSR & SSG: Hỗ trợ Server-Side Rendering và Static Site Generation.
  • Local mutation (Optimistic UI): Cập nhật giao diện ngay lập tức mà không cần chờ server.
  • TypeScript + Suspense + React Native: Hỗ trợ đầy đủ TypeScript, React Suspense và React Native.

💡 Vì sao đáng chú ý

SWR không chỉ đơn thuần là một công cụ fetch dữ liệu — nó biến toàn bộ luồng cập nhật thành một dòng dữ liệu liên tục và tự động. Thay vì viết thủ công logic loading, error, cache…, chỉ với một hook useSWR, component nhận được data, isLoading, và error một cách trọn gói. Điều này giúp UI luôn nhanh, phản hồi nhanh và giảm đáng kể đường dẫn logic phức tạp.

Dự án phù hợp với mọi ứng dụng React cần quản lý trạng thái dữ liệu động — từ dashboard, blog, app mobile (React Native) cho đến các dự án JAMstack với SSR/SSG.


#React #DataFetching #Hooks #Vercel #OpenSource #TiniX

Similar Projects

Discover other similar projects and AI models.

RepositoryTypeScript
TanStack/query

🤖 Powerful asynchronous state management, server-state utilities and data fetching for the web. TS/JS, React Query, Solid Query, Svelte Query and Vue Query.

50.7k
Nov 26, 2026
RepositoryTypeScript
ConsoleTVs/sswr

🔥 Svelte stale while revalidate (SWR) data fetching strategy

295
Jun 14, 2026
RepositoryTypeScript
ConsoleTVs/vswr

🔥 Stale-While-Revalidate (SWR) strategy to fetch data in Vue 3

106
Mar 29, 2022
RepositoryC++
react/react-native

A framework for building native applications using React

127.0k
Nov 27, 2026
RepositoryTypeScript
storybookjs/storybook

Storybook is the industry standard workshop for building, documenting, and testing UI components in isolation

91.8k
Nov 29, 2026
RepositoryTypeScript
ChatGPTNextWeb/NextChat

✨ Zero-config AI chat assistant. No API key needed — sign up and instantly chat with GPT-5, Claude 4, Gemini 2.5, DeepSeek & 100+ top models. Pay-as-you-go saves you more. Available on Web, iOS, macOS, Android, Linux, Windows.

89.0k
Oct 20, 2026
RepositoryJavaScript
vercel/next.js

The React Framework

143.9k
Dec 1, 2026
RepositoryJavaScript
vercel/next.js

The React Framework

143.9k
Dec 1, 2026
Repository
enaqx/awesome-react

A collection of awesome things regarding React ecosystem

75.4k
Sep 4, 2026