Next.js Discord

Discord Forum

⨯ useSearchParams() should be wrapped in a suspense boundary at page "/404"

Answered
Trigg Hound posted this in #help-forum
Open in Discord
Trigg HoundOP
I get an error while building, but dev works.
The log
C:\Users\issac\vscodeprojects\myextraduty>npm run build

> myextraduty@0.1.0 build
> next build

   â–² Next.js 14.1.0
   - Environments: .env

   Creating an optimized production build ...
 ✓ Compiled successfully
 ✓ Linting and checking validity of types
 ✓ Collecting page data
   Generating static pages (0/15)  [    ]
 ⨯ useSearchParams() should be wrapped in a suspense boundary at page "/404". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout

Error occurred prerendering page "/_not-found". Read more: https://nextjs.org/docs/messages/prerender-error

 ✓ Generating static pages (15/15)

> Export encountered errors on following paths:
        /_not-found


not-found.tsx
import { Button } from "@/components/ui/button";
import { bricolage } from "./fonts";

export default function FourOFour() {
  return (
    <div className="flex justify-center items-center w-screen h-screen">
      <div className="flex flex-col items-center gap-4">
        <span className={`${bricolage.className} text-9xl opacity-40 font-black`}>404</span>
        <span>The requested page could not be found.</span>
        <Button>Go back to the home page</Button>
      </div>
    </div>
  );
}


GitHub: https://github.com/YTG2G3/myextraduty/tree/migi
Answered by Nelson
Because in next-nprogress-bar, it used useSearchParams.
Wrapping the ProgressBar in a <Suspense> can fix the problem.
View full answer

5 Replies

thats very weird, have you made sure to delete .next folder and try again
Trigg HoundOP
Still getting the same error
Trigg HoundOP
problem found, next-nprogress-bar
ahh thats weird
Because in next-nprogress-bar, it used useSearchParams.
Wrapping the ProgressBar in a <Suspense> can fix the problem.
Answer