Dev Helpers
← Back

Date range route form

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

Open this example in the interactive library

Source code

// components/DateRangeRouteForm.tsx

import Form from "next/form";

export default function DateRangeRouteForm({
  action = "/search",
}: { action?: string } = {}) {
  return (
    <Form action={action}>
      <label>
        From
        <input name="from" type="date" />
      </label>
      <label>
        Through
        <input name="to" type="date" />
      </label>
      <button>Show range</button>
    </Form>
  );
}