Dev Helpers
← Back

Next results boundary

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

Open this example in the interactive library

Source code

// components/NextResultsBoundary.tsx

import Link from "next/link";

export default function NextResultsBoundary({
  page = 2,
  total = 5,
  base = "/articles",
}: { page?: number; total?: number; base?: string } = {}) {
  return page < total ? (
    <Link rel="next" href={{ pathname: base, query: { page: page + 1 } }}>
      Next results →
    </Link>
  ) : (
    <p>End of results</p>
  );
}