Dev Helpers
← Back

Route-bound form key

Place this file at components/RouteBoundFormKey.tsx in an App Router project. Mount inside a route with the named dynamic segments shown in useParams.

Open this example in the interactive library

Source code

"use client";

// components/RouteBoundFormKey.tsx

import { useParams } from "next/navigation";

export default function RouteBoundFormKey() {
  const { slug } = useParams<{ slug: string }>();
  return (
    <label key={slug}>
      Notes for {slug}
      <textarea defaultValue="" />
    </label>
  );
}