How to enable redirect in next-fetch

by mmyoji

1 min read

next-fetch is useful when you use both SWR and Next.js API Routes.

But currently the documentation is poor. I am a bit struggled with how to use hookResponse option in query or mutation.

Usage

⚠️ This is just for @next-fetch/swr@0.0.2 and could be changed in future versions.

For API routes, see the doc.

// pages/form.tsx

export default function MyFormPage() {
  return (
    <form action="/api/simple?__handler=useMutation" method="POST">
      <input type="text" name="name" />
      <button type="submit">Submit</button>
    </form>
  );
}