Skip to content

Comments

🐛 Fix: resolve hydration mismatch in RelatedProjects links#1190

Merged
clubanderson merged 1 commit intokubestellar:mainfrom
oksaumya:ssr
Feb 24, 2026
Merged

🐛 Fix: resolve hydration mismatch in RelatedProjects links#1190
clubanderson merged 1 commit intokubestellar:mainfrom
oksaumya:ssr

Conversation

@oksaumya
Copy link
Member

📌 Fixes

Fixes #1189


📝 Summary of Changes

Resolved a hydration mismatch issue in the RelatedProjects component where SSR and client rendered different href attributes.

Problem

Server rendered:
href="https://kubestellar.io/docs"

Client rendered:
href="/docs"

This triggered a React hydration warning.

Solution

• Normalized projectUrl generation
• Ensured consistent link rendering across SSR and client
• Removed non-deterministic URL logic

Result

  • No hydration warnings
  • Stable React hydration
  • Consistent markup

Affected File

src/components/docs/RelatedProjects.tsx


Changes Made

  • Updated ...
  • Refactored ...
  • Fixed ...
  • Added tests for ...

Checklist

Please ensure the following before submitting your PR:

  • I have reviewed the project's contribution guidelines.
  • I have written unit tests for the changes (if applicable).
  • I have updated the documentation (if applicable).
  • I have tested the changes locally and ensured they work as expected.

Screenshots or Logs (if applicable)


👀 Reviewer Notes

Add any special notes for the reviewer here

Signed-off-by: saumya <saumyakr2006@gmail.com>
Copilot AI review requested due to automatic review settings February 22, 2026 19:41
@kubestellar-prow kubestellar-prow bot added the dco-signoff: yes Indicates the PR's author has signed the DCO. label Feb 22, 2026
@kubestellar-prow
Copy link

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign btwshivam for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@netlify
Copy link

netlify bot commented Feb 22, 2026

Deploy Preview for kubestellar-docs ready!

Built without sensitive environment variables

Name Link
🔨 Latest commit c1feb2c
🔍 Latest deploy log https://app.netlify.com/projects/kubestellar-docs/deploys/699b5c035f2d2600085e173c
😎 Deploy Preview https://deploy-preview-1190--kubestellar-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@github-actions
Copy link
Contributor

Welcome to KubeStellar! 🚀 Thank you for submitting this Pull Request.

Before your PR can be merged, please ensure:

DCO Sign-off - All commits must be signed off with git commit -s to certify the Developer Certificate of Origin

PR Title - Must start with an emoji: ✨ (feature), 🐛 (bug fix), 📖 (docs), 🌱 (infra/tests), ⚠️ (breaking change)

Getting Started with KubeStellar:

Contributor Resources:


🌟 Help KubeStellar Grow - We Need Adopters!

Our roadmap is driven entirely by adopter feedback. Whether you're using KubeStellar yourself or know someone who could benefit from multi-cluster Kubernetes:

📋 Take our Multi-Cluster Survey - Share your use cases and help shape our direction!


A maintainer will review your PR soon. Feel free to ask questions in the comments or on Slack!

@kubestellar-prow kubestellar-prow bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Feb 22, 2026
@github-actions github-actions bot added frontend typescript and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Feb 22, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes a React hydration mismatch in the docs sidebar’s RelatedProjects component by making the initial SSR and client render produce consistent href attributes for project links.

Changes:

  • Introduced isProduction as state with a post-mount hostname check (instead of computing it during render).
  • Adjusted URL generation flow to avoid SSR/client divergence for link hrefs.
  • Added suppressHydrationWarning to related project <a> links.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +37 to +40
const checkProduction =
window.location.hostname === 'kubestellar.io' ||
window.location.hostname === 'www.kubestellar.io' ||
window.location.hostname === 'localhost';
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The hostname check treats localhost as “production” but does not include other common local hosts like 127.0.0.1 (or ::1). If the site is accessed via those, checkProduction becomes false and links get rewritten to the production domain after mount, which is unexpected for local development. Consider expanding the local-host allowlist (the repo already checks for 127.0.0.1 elsewhere, e.g. src/lib/url.ts).

Suggested change
const checkProduction =
window.location.hostname === 'kubestellar.io' ||
window.location.hostname === 'www.kubestellar.io' ||
window.location.hostname === 'localhost';
const checkProduction =
window.location.hostname === 'kubestellar.io' ||
window.location.hostname === 'www.kubestellar.io' ||
window.location.hostname === 'localhost' ||
window.location.hostname === '127.0.0.1' ||
window.location.hostname === '::1';

Copilot uses AI. Check for mistakes.
<a
key={project.title}
href={projectUrl}
suppressHydrationWarning
Copy link

Copilot AI Feb 22, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suppressHydrationWarning on the <a> tag will silence any future SSR/client attribute mismatches for this link (not just the original href issue), which can hide real bugs. If the goal is “consistent link rendering across SSR and client”, it’s better to make projectUrl deterministic for the initial render and drop this suppression once the underlying mismatch is resolved.

Suggested change
suppressHydrationWarning

Copilot uses AI. Check for mistakes.
@oksaumya
Copy link
Member Author

/ok-to-test

@kubestellar-prow kubestellar-prow bot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Feb 23, 2026
Copy link
Contributor

@clubanderson clubanderson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review

Good fix. Moving the isProduction hostname check from render-time typeof window into React state initialized via useEffect is the correct Next.js/React pattern and eliminates the SSR/client hydration mismatch.

One suggestion: The suppressHydrationWarning on the <a> tags is now redundant since the state-based approach eliminates the mismatch. Consider removing it — leaving it in masks any future hydration issues on those elements.

Merge order note: This PR and #1195 both modify RelatedProjects.tsx. This one should merge first as it's the more foundational fix. #1195 will need a rebase after.

/lgtm

@kubestellar-prow kubestellar-prow bot added the lgtm Indicates that a PR is ready to be merged. label Feb 24, 2026
@kubestellar-prow
Copy link

LGTM label has been added.

DetailsGit tree hash: 75b88a64e253dcef4eeed2b0c8f11b17adef3ad3

@clubanderson clubanderson merged commit e5f6f07 into kubestellar:main Feb 24, 2026
24 of 25 checks passed
Copilot AI added a commit that referenced this pull request Feb 24, 2026
…matting

- Add isProduction as useState(true) + useEffect (from #1190) to avoid render-time window check
- Remove render-time typeof window !== 'undefined' isProduction check
- Restore Moon/Sun className to original 3-line format (revert unrelated reformatting)
- Add suppressHydrationWarning to <a> tag (from #1190)
- Keep hover fix: hoveredProject state, onMouseEnter/onMouseLeave, bgColor logic

Co-authored-by: clubanderson <407614+clubanderson@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dco-signoff: yes Indicates the PR's author has signed the DCO. frontend lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. typescript

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hydration mismatch in RelatedProjects component (SSR vs Client HTML)

2 participants