prevent-hydration-mismatch-without-flickering

Inject a synchronous script to update the DOM before React hydration.

Updated Feb 10, 2026
One-click install
npx skills add https://github.com/ihj04982/my-cursor-settings --skill prevent-hydration-mismatch-without-flickering
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: prevent-hydration-mismatch-without-flickering
Source: https://github.com/ihj04982/my-cursor-settings/tree/main/skills/prevent-hydration-mismatch-without-flickering
Command: npx skills add https://github.com/ihj04982/my-cursor-settings --skill prevent-hydration-mismatch-without-flickering

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill prevents visual flickering and hydration mismatches in web applications that rely on client-side data like localStorage or cookies, ensuring a smooth user experience from the moment the page loads.

Core Features & Use Cases

  • Synchronous DOM Updates: Injects a script to update the DOM before client-side frameworks like React hydrate.
  • SSR Compatibility: Avoids errors during Server-Side Rendering by not accessing browser-specific APIs directly in the initial render.
  • Use Case: Ideal for managing user themes, authentication states, or any preference stored client-side, ensuring the UI reflects the correct state immediately without a perceptible delay or change.

Quick Start

Implement the provided React component pattern to ensure client-side data is applied before hydration.

Frequently Asked Questions about prevent-hydration-mismatch-without-flickering

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I prevent React hydration mismatch errors when reading localStorage?

UI flickering during SSR hydration occurs because the server renders a default state while the client immediately updates it based on localStorage or cookies. This Skill injects a synchronous script to apply client-side data before the framework hydrates, ensuring the UI matches the expected state instantly.

What is the best way to apply a dark theme from cookies without UI flicker?

The best way to apply a dark theme from cookies without UI flicker is to use a synchronous DOM update script before hydration. This approach updates the theme state immediately on load, avoiding the perceptible delay and visual change that happens when client-side preferences are applied after the initial render.

Can I use this hydration fix for user authentication states in SSR?

Yes, you can use this hydration fix for user authentication states in SSR. It is specifically designed to manage client-side data like authentication states and user preferences, ensuring the UI reflects the correct state immediately without causing Server-Side Rendering breakage or hydration mismatches.

Why does my React app flicker when loading user preferences from client-side storage?

Your React app flickers because the server renders an initial HTML state that differs from the client-side storage values applied during hydration. Injecting a synchronous script to update the DOM before hydration prevents this visual delay and ensures immediate correct rendering.

Do I need to configure Server-Side Rendering to avoid hydration mismatches?

You do not need to reconfigure Server-Side Rendering itself to avoid hydration mismatches. This Skill prevents SSR breakage by injecting a synchronous script on the client that updates the DOM before the framework hydrates, bypassing direct browser API access during the initial render.