Open this example in the interactive library
Source code
"use client";
// components/CurrentSortSummary.tsx
import { Suspense } from "react";
import { useSearchParams } from "next/navigation";
function CurrentSortSummaryContent() {
const params = useSearchParams();
const sort = params.get("sort");
return (
<p>
Sorted by {sort === "price" ? "price" : sort === "name" ? "name" : "most recent"}
</p>
);
}
export default function CurrentSortSummary() {
return (
<Suspense fallback={<span>Loading view…</span>}>
<CurrentSortSummaryContent />
</Suspense>
);
}
