Skip to content

[Fix] Load react-json-view browser-only (SSR document crash) - #1726

Merged
CREDO23 merged 1 commit into
MODSetter:devfrom
CREDO23:fix/json-view-ssr
Aug 29, 2026
Merged

[Fix] Load react-json-view browser-only (SSR document crash)#1726
CREDO23 merged 1 commit into
MODSetter:devfrom
CREDO23:fix/json-view-ssr

Conversation

@CREDO23

@CREDO23 CREDO23 commented Aug 29, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • @microlink/react-json-view reads document at module-eval time, throwing ReferenceError: document is not defined under SSR (via json-view -> citations panel / playground run-detail) despite "use client".
  • Load it through next/dynamic with ssr: false; InteractionProps becomes a type-only import. Single importer, so all consumers are covered.

Test plan

  • Open a chat/playground run with citations or JSON output — renders with no server console error
  • /dashboard/.../new-chat/* returns 200 with no document is not defined

High-level PR Summary

This PR fixes a server-side rendering (SSR) crash caused by @microlink/react-json-view accessing the document object during module evaluation. The fix wraps the component import with Next.js's dynamic() function and disables SSR (ssr: false), ensuring the library only loads in the browser. The InteractionProps type is converted to a type-only import since it doesn't require runtime evaluation.

⏱️ Estimated Review Time: 5-15 minutes

💡 Review Order Suggestion
Order File Path
1 surfsense_web/components/json-view.tsx

Need help? Join our Discord

@microlink/react-json-view touches `document` at module-eval time, so it
threw ReferenceError under SSR (via json-view -> citations / playground
run-detail) despite the "use client" directive. Load it through
next/dynamic with ssr:false; the InteractionProps import becomes type-only.
@vercel

vercel Bot commented Aug 29, 2026

Copy link
Copy Markdown

@CREDO23 is attempting to deploy a commit to the Rohan Verma's projects Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e266908a-b9d8-4a74-8427-597d01aa6d08

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@CREDO23
CREDO23 merged commit f6ce59f into MODSetter:dev Aug 29, 2026
4 of 9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant