Skip to content

Error console issue: Fallback data is required when using Suspense in SSR #4159

@zhiyanzhaijie

Description

@zhiyanzhaijie

Bug report

Image

Description / Observed Behavior

When using swr suspense: true in use client; component wrapped in a suspense boundry. It always come out with that error console in server side, both in env of development and production.

I have try the followed ways to solve:

  1. add swr config - fallbackdata.

error disappear. But my component ui went wrong - first-time UI rendered with fallbackdata, then suspense fallback, finally the seccess-data fallback or error-fallback

  1. adjust component code with isMounted state checked(see the comments part in screenshot that pasted),

I don't know what actually it happens, but it seems the ssr logic don't go through my component anymore, so it works. The problem is my component code is more complex now and i doubt that it got a worse performance.

Repro Steps / Code Example

  1. create a client-side comp with suspense: true swr using, wrapped in a react/Suspense
  2. when the component mounted, the console error will show in node side.

Additional Context

versions:

swr: 2.3.3.
nextjs: 15.3.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions