Skip to content

fix: resolve Next.js hydration mismatches for browser APIs#1390

Open
Abhishek2005-ard wants to merge 9 commits into
magic-peach:mainfrom
Abhishek2005-ard:fix/react-hydration-mismatches
Open

fix: resolve Next.js hydration mismatches for browser APIs#1390
Abhishek2005-ard wants to merge 9 commits into
magic-peach:mainfrom
Abhishek2005-ard:fix/react-hydration-mismatches

Conversation

@Abhishek2005-ard
Copy link
Copy Markdown

Description

This PR resolves two React Hydration Mismatch errors that were triggering the Next.js error overlay in development.

The mismatches occurred because the application was directly evaluating browser-specific APIs (localStorage and navigator.platform) during the initial render cycle. Because these APIs either do not exist or evaluate differently during Server-Side Rendering (SSR), the server-rendered HTML did not match the initial client hydration payload.

Changes Made

  • useVideoEditor.ts: Refactored the soundOnCompletion initialization. It now initializes cleanly to its default value and uses a useEffect to safely read and apply the user's saved preference from localStorage post-hydration.
  • VideoEditor.tsx: Converted the isMac constant into a state variable and moved the navigator.platform check into a useEffect hook to prevent text node mismatches between "Ctrl" + Enter (server) and "⌘" + Enter (Mac client).

Testing Instructions

  1. Run npm run dev to start the Next.js development server.
  2. Open the application in your browser.
  3. Verify that the red "1 Issue" error overlay no longer appears in the bottom left corner.
  4. If testing on a Mac, verify that the keyboard shortcut correctly updates to display "⌘" + Enter after the initial page load.

close #1387

@vercel
Copy link
Copy Markdown

vercel Bot commented May 29, 2026

@Abhishek2005-ard is attempting to deploy a commit to the magic-peach1's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions
Copy link
Copy Markdown
Contributor

👋 Thanks for your PR, @Abhishek2005-ard!

Welcome to Reframe — a browser-based video editor built for everyone 🎬

What happens next

  1. 🤖 Automated checks — build & TypeScript typecheck will run automatically
  2. Vercel preview — a preview deployment will be created (requires maintainer authorization for fork PRs)
  3. 👀 Code review — a maintainer will review your changes
  4. 🚀 Merge — once approved, your PR will be merged!

Quick checklist

  • PR title follows Conventional Commits (e.g. feat: add dark mode)
  • Linked the issue this PR closes (e.g. Closes #123)
  • Tested the changes locally (bun run dev)
  • Build passes (bun run build)

Useful links

Happy coding! 🎉

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 29, 2026

✅ PR Format Check Passed — @Abhishek2005-ard

Basic format checks passed. A maintainer will review your code changes.

This does not mean the PR is approved — it just means the format is correct.

@github-actions github-actions Bot added level:advanced Advanced level - 55 pts type:bug Bug fix type:testing Testing labels May 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

level:advanced Advanced level - 55 pts type:bug Bug fix type:testing Testing

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] React Hydration Mismatches caused by direct browser API checks during initial render

1 participant