Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build for "With Segment Analytics" example #74924

Open
wants to merge 2 commits into
base: canary
Choose a base branch
from

Conversation

loderunner
Copy link

What?

This PR fixes build for the With Segment Analytics example.

Why?

The example worked in dev mode, but not in build.

The error stems from next build trying to pre-render the Analytics component which uses useSearchParams, a client-only hook.

Error message:

useSearchParams() should be wrapped in a suspense boundary at page "/". Read more: https://nextjs.org/docs/messages/missing-suspense-with-csr-bailout

How?

  • Wrapped the Analytics component in a Suspense
  • Moved the component inside body to prevent React Hydration mismatch issues

@ijjk ijjk added the examples Issue was opened via the examples template. label Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
examples Issue was opened via the examples template.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants