Skip to content
Discussion options

You must be logged in to vote

SWR doesn't have a way to do that currently. As a workaround, you can do this manually:

const { data, mutate } = useSWR('/api')

// you can use any lib such as https://usehooks-typescript.com/use-interval
// to control the behavior precisely, even calculate the remaining time
useInterval(() => {
  // this will trigger a refresh
  mutate()
}, 5000)

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@niraj8
Comment options

Answer selected by niraj8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants