Skip to content

Usage of SanityLive causes "Bail out to client-side rendering: next/dynamic" error #2525

@ragnsan

Description

@ragnsan

Describe the bug

Using the SanityLive component as described in https://github.com/sanity-io/sanity-template-nextjs-clean/blob/main/frontend/app/layout.tsx causes pages to bail out to client rendering.

I am on Next.js 15 with the latest sanity and next-sanity version. Have tried other versions as well.

Have export const dynamic = 'error' on all pages to enforce SSG. Builds work just fine.

In local dev I get this error if I open up the page source. If I open up the same page in production, I don't see the error. But if I put the page into any JSON-LD verifying tool like Schema Markup Validator it throws an error and does not parse and schema markup in that page or any other page. If I remove the SanityLive component I don't get this problem. If I remove the SanityLive component in local dev I don't get the "Bail out to client-side rendering: next/dynamic" error either.

To Reproduce
Steps to reproduce the behavior:

Make a Next.js project with the same versions of next and sanity mentioned below.

Open up a page where its root layout has the SanityLive component

Open up the page source code

Expected behavior
SanityLive to work like it does without breaking the prerendered state of my pages.

Screenshots

Image Image Image Image

Which versions of Sanity are you using?
@sanity/cli (global) 3.90.0 (latest: 3.93.0)
@sanity/cli 3.93.0 (up to date)
sanity 3.93.0 (up to date)
nextjs ^15.3.4
next-sanity ^9.12.0

What operating system are you using?
MacOS

Which versions of Node.js / npm are you running?
10.9.2
v22.16.0

Additional context
I've had this problem with several projects recently, but the JSON-LD validation works most of the time in those projects. In this project it does not work at all

Add any other context about the problem here.

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