Skyleen77 / next-nprogress-bar

NProgress integration on Next.js compatible with /app and /pages folders

Home Page:https://next-nprogress-bar.vercel.app

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is there a reason for making the whole layout client side?

tomelliot opened this issue · comments

More of a question than an issue - is there a reason to make the whole layout.tsx "use client", rather than just the ? That seems to defeat the purpose of NextJS's server side rendering.

I've embedded the progress bar in a component, which is marked "use client" and then imported into the layout.tsx, so the layout can stay server side. It seems to be working - any reasons why that wouldn't work?

The component must be used in a "use client" because it uses react hooks (which only work on the client side).

The solution I proposed in the readme is to create a "use client" provider that you add to your layout.tsx, without having to put "use client" in your layout.tsx.

I hope I was able to answer your question.

Oh I see - I misunderstood your documentation here, my bad. I just made a little PR if you're open to suggestions.