#Error with Suspense?
1 messages · Page 1 of 1 (latest)
Hi @silver obsidian. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
This error message indicates that there was an issue during server-side rendering of a Suspense boundary in your Next.js application. As a result, Next.js switched to client-side rendering for this Suspense boundary.
In Next.js, you can manually create Suspense boundaries for your own UI components. The App Router supports streaming with Suspense for both Node.js and Edge runtimes. If a route is statically rendered, calling useSearchParams() will cause the tree up to the closest Suspense boundary to be client-side rendered. This allows a part of the page to be statically rendered while the dynamic part that uses searchParams is client-side rendered. You can reduce the portion of the route that is client-side rendered by wrapping the component that uses useSearchParams in a Suspense boundary.
Here's an example of how to use Suspense with useSearchParams:
'use client'
import { useSearchParams } from 'next/navigation'
export default function SearchBar() {
const searchParams = useSearchParams()
const search = searchParams.get('search')
// This will not be logged on the server when using static rendering
console.log(search)
return <>Search: {search}</>
}
If an error occurs during server-side rendering within a Suspense boundary, it's possible that there's an issue with the component that's being rendered. You might want to check the component for any potential issues.