wsimmonds avatar

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-code

Installs into .claude/skills of the current project.

Files

Next.js: useSearchParams with Suspense Pattern

Pattern Overview

The useSearchParams hook requires TWO things:

  1. Component must have 'use client' directive
  2. 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

More from wsimmonds/claude-nextjs-skills

All 9
1wsimmonds avatarnextjs-pathname-id-fetchwsimmonds/claude-nextjs-skillsFocused pattern for fetching data using URL parameters in Next.js. Covers creating dynamic routes ([id], [slug]) and accessing route parameters in server compon296skills.sh installs
2wix avatarwix-cli-site-widgetwix/skillsUse when building interactive widgets, custom data displays, or configurable site components with settings panels. Triggers include widget, custom element, inte288skills.sh installs
3tech-leads-club avatarperf-astrotech-leads-club/agent-skillsAstro-specific performance optimizations for 95+ Lighthouse scores. Covers critical CSS inlining, compression, font loading, and LCP optimization. Use when opti286skills.sh installs
4patricio0312rev avatarreact-server-componentspatricio0312rev/skillsImplements React Server Components (RSC) patterns with Next.js App Router including data fetching, streaming, selective hydration, and server/client composition284skills.sh installs
5gentleman-programming avatartailwind-4gentleman-programming/gentleman-skillsTailwind CSS 4 patterns and best practices. Trigger: When styling with Tailwind - cn(), theme variables, no var() in className.279skills.sh installs
6thedivergentai avatargodot-ui-containersthedivergentai/gd-agentic-skillsExpert blueprint for responsive UI layouts using Container nodes (HBoxContainer, VBoxContainer, GridContainer, MarginContainer, ScrollContainer, HFlowContainer,279skills.sh installs