Immutable requests
@kubb/plugin-swr generates a useFoo hook whose second argument accepts a Kubb-specific immutable switch. Set it to true for data that never changes once loaded, so SWR fetches the resource once and skips revalidation on stale, focus, and reconnect.
typescript
import { defineConfig } from 'kubb/config'
import { pluginTs } from '@kubb/plugin-ts'
import { pluginFetch } from '@kubb/plugin-fetch'
import { pluginSwr } from '@kubb/plugin-swr'
export default defineConfig({
input: './petStore.yaml',
output: { path: './src/gen', clean: true },
plugins: [pluginTs(), pluginFetch(), pluginSwr()],
})typescript
import { useGetPetById } from './gen/hooks/useGetPetById'
const { data } = useGetPetById({ path: { petId: 1 } }, { immutable: true })