How to mutate multiple SWR keys

Viewed 896

I'm using SWR to show a paginated component, very similar to the example in the docs. My key looks something like

useSWR(`/api/items?offset=${offset}`)

I would like to upload a new list of items, and I want to tell SWR to revalidate all items requests since they will no longer be valid. I'm assuming mutate is still the right avenue to do this, but is there a way that I can tell mutate to invalidate many keys at once? Or ever better, all keys that match /api/items(.*)?

Thank you!

0 Answers
Related