Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Next suspense with swr, "Fallback data is required when using suspense in SSR."

I'm trying to use React Suspense within a Next project

I'm not using SSR, the app is only used as client rendering

Supense works, but I got this error :

Fallback data is required when using suspense in SSR.

  <Suspense fallback={<Skeleton />}>
     <Foo />
  </Suspense>
export const Foo = () => {
    const { data, error, isLoading } = useSWR(
        `/api/foo`,
        async (url: string) => await ApiClient.GET(url),
        { suspense: true }
    )
    return <Bar data={data} />
}
like image 337
Xero Avatar asked Dec 01 '25 16:12

Xero


1 Answers

I also am facing this.

However, from this section of the documentation I believe that it is ignorable in our cases. https://swr.vercel.app/docs/suspense#server-side-rendering

It appears to be triggering that error during the 'pre-rendering' stage.

like image 78
Connoropolous Avatar answered Dec 03 '25 10:12

Connoropolous



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!