Dev Helpers
← Back

Search route form

Place this file at components/SearchRouteForm.tsx in an App Router project.

Open this example in the interactive library

Source code

// components/SearchRouteForm.tsx

import Form from "next/form";

export default function SearchRouteForm({
  action = "/search",
}: { action?: string } = {}) {
  return (
    <Form action={action}>
      <label>
        Keywords
        <input name="q" type="search" required />
      </label>
      <button>Search</button>
    </Form>
  );
}