Next.js Discord

Discord Forum

Dynamic Import Causing Blank Page

Unanswered
Stony gall posted this in #help-forum
Open in Discord
Stony gallOP
I have a client component which uses [useLocalStorage](https://usehooks.com/uselocalstorage). I was getting Error: useLocalStorage is a client-only hook, and [this post](https://stackoverflow.com/questions/77783771/next-js-has-is-a-client-only-hook-error) suggested that I dynamically import the client component to fix this problem. When I import the component in my server page.tsx component, the layout (ie. my navbar) loads, then half a second later, the page goes blank (and I lose the page title, ie. goes to localhost:3000/...). However, the error is gone. In page.tsx, I'm importing the component like this:

const CreatePost = dynamic(
  () => import('@/app/(main)/create/components/createPost'),
  { ssr: false }
);

0 Replies