79755525

Date: 2025-09-04 09:38:32
Score: 1
Natty:
Report link

The LocalStorage component is really only client side. So I think import it with { ssr: false } is reasonable.

Suppose you want to use your LocalStorage component within Foo component in the same directory level.

.
├── foo.tsx
└── local-storage.tsx
// foo.tsx
"use client";
import dynamic from "next/dynamic";
const LocalStorage = dynamic(() => import("./local-storage"), { ssr: false });

const Foo:React.FC = () => (
    <LocalStorage />
)

export default Foo;

see https://nextjs.org/docs/messages/react-hydration-error#solution-2-disabling-ssr-on-specific-components

Reasons:
  • Probably link only (1):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: LiHS