# Integrating the SWR library with a type-safe API client

DevFeed: [Integrating the SWR library with a type-safe API client](<https://devfeed.tech/articles/integrating-the-swr-library-with-a-type-safe-api-client-11841.md>)

Original publisher: [Read original article](<https://incident.io/blog/integrating-the-swr-library>)

Author: Isaac Seymour

Published: 2023-08-23T23:18:00Z

Content type: article

Language: en

Sources: [The incident.io Blog](<https://devfeed.tech/sources/the-incident-io-blog.md>)

Topics: [Front end](<https://devfeed.tech/topics/frontend.md>), [Caching](<https://devfeed.tech/topics/caching.md>), [React](<https://devfeed.tech/topics/react.md>), [OpenAPI Specification](<https://devfeed.tech/topics/openapi.md>), [TypeScript](<https://devfeed.tech/topics/typescript.md>), [API](<https://devfeed.tech/topics/api.md>)

Tags: [api](<https://devfeed.tech/tags/api.md>), [building](<https://devfeed.tech/tags/building.md>), [caching](<https://devfeed.tech/tags/caching.md>), [incident](<https://devfeed.tech/tags/incident.md>), [incident-channel](<https://devfeed.tech/tags/incident-channel.md>), [incident-management](<https://devfeed.tech/tags/incident-management.md>), [incident-response](<https://devfeed.tech/tags/incident-response.md>), [openapi](<https://devfeed.tech/tags/openapi.md>), [outage](<https://devfeed.tech/tags/outage.md>), [post-mortem](<https://devfeed.tech/tags/post-mortem.md>), [react](<https://devfeed.tech/tags/react.md>), [slack-incident](<https://devfeed.tech/tags/slack-incident.md>), [typescript](<https://devfeed.tech/tags/typescript.md>)

## AI overview

This article describes integrating the SWR library into a React application through a type-safe API client. It explains stale-while-revalidate caching, shared cached API responses, cache-key consistency, and the use of TypeScript generics with an OpenAPI-generated client.

## Source excerpt

Once API responses in our app are loaded into the cache, we don't need to wait to refetch them if another page needs them.