
If you've hit the Next.js error about useSearchParams needing a Suspense boundary, this walks you through the required pattern. Every component using useSearchParams needs both the 'use client' directive and a Suspense wrapper around it. The skill covers the two main approaches (separate component vs inline), shows how to read and update URL params for search interfaces, filters, and pagination, and includes practical examples with TypeScript types. It also demonstrates working with URLSearchParams methods and updating the URL without page refreshes using useRouter. Useful reference when building any feature that reads query strings client-side in Next.js App Router.
$ npx -y skills add wsimmonds/claude-nextjs-skills --skill nextjs-use-search-params-suspense --agent claude-codeInstalls into .claude/skills of the current project.
The useSearchParams hook requires TWO things:
'use client' directive<Suspense> boundaryThis is a Next.js requirement, not optional!
useSearchParams reads URL query parameters:
/search?q=shoes → searchParams.get('q') returns "shoes"/products?category=electronics&sort=price → Read multiple paramsWhy Suspense? Next.js uses React 18's Suspense to handle the async nature of reading URL params during server-side rendering and hydration.
// app/page.tsx
import { Suspense } from 'react';
import SearchComponent from './SearchComponent';
export default function Page() {
return (
<Suspense fallback={<div>Loading...</div>}>
<SearchComponent />
</Suspense>
);
}
// app/SearchComponent.tsx
'use client';
import { useSearchParams } from 'next/navigation';
export default function SearchComponent() {
const searchParams = useSearchParams();
const query = searchParams.get('q') || '';
Sponsors