The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
import { mutate } from "swr";
export const mutatePrefix = (prefix: string | string[]) =>
mutate(
(key) =>
typeof key === "string" &&
(Array.isArray(prefix)
? prefix.some((p) => key.startsWith(p))
: key.startsWith(prefix)),
undefined,
{ revalidate: true },
);
export const mutateSuffix = (suffix: string | string[]) =>
mutate(
(key) =>
typeof key === "string" &&
(Array.isArray(suffix)
? suffix.some((s) => key.endsWith(s))
: key.endsWith(suffix)),
undefined,
{
revalidate: true,
},
);