
Nextjs Use Search Params Suspense
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.
- skills.sh installs
- 313
- GitHub stars
- 110
- last updated
- Aug 21, 2026
Install
$ npx -y skills add wsimmonds/claude-nextjs-skills --skill nextjs-use-search-params-suspense --agent claude-codeInstalls into .claude/skills of the current project.
Files
Next.js: useSearchParams with Suspense Pattern
Pattern Overview
The useSearchParams hook requires TWO things:
- Component must have
'use client'directive - Component must be wrapped in a
<Suspense>boundary
This is a Next.js requirement, not optional!
Why This Pattern?
useSearchParams reads URL query parameters:
/search?q=shoes→searchParams.get('q')returns"shoes"/products?category=electronics&sort=price→ Read multiple params
Why Suspense? Next.js uses React 18's Suspense to handle the async nature of reading URL params during server-side rendering and hydration.
The Pattern
Single-File Pattern (Recommended)
// 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
Details
- Repository
- github.com/wsimmonds/claude-nextjs-skills
- Category
- Frontend Development
- First seen
- Jun 3, 2026