Home / Companies / LogRocket / Blog / Post Details
Content Deep Dive

SWR v1 is here: What’s new?

Blog post from LogRocket

Post Details
Company
Date Published
Author
Lawrence Eagles
Word Count
1,669
Language
-
Hacker News Points
-
Summary

SWR, a React hooks library for remote data fetching, has introduced several new features in its version 1 release that enhance its performance and flexibility. The update includes a smaller library size with improved performance through tree shaking, path imports, and a custom cache provider allowing for more adaptable storage options. Users can now access global configuration options within React components using the new useSWRConfig() hook, and the library supports immutable mode to keep fetched states unchanged during revalidation. Additionally, SWR v1 offers middleware support for logic abstraction, allowing developers to implement features like request logging, and introduces fallback data to provide prefetched content during revalidation, enhancing user experience in scenarios such as static site generation and server-side rendering. Overall, SWR remains a lightweight and efficient solution for data fetching in React applications, supporting both REST and GraphQL, with full TypeScript compatibility.