next.jsnext.js13client-side-rendering

Nextjs client-side rendering not working?


I have created a project in nextjs 13 using app router. I want to acheive client-side rendering. In their documentation it is mentioned that for rendering on client-side, add 'use client' at the top of file and that will be rendered on client-side. but unfortunately i am not able to have its effects of client-side. i am stuck with that.

This is my page.js file:

'use client';

import { useState } from 'react'

export default function Counter() {
  const [count, setCount] = useState(0)
  console.log("counter")

  return (
    <div>
      <p>You clicked {count} times</p>
      <button onClick={() => setCount(count + 1)}>Click me</button>
    </div>
  )
 }

It should be rendered on client-side but it's not.


Solution

  • i fixed that issue, actually i installed nodejs updated version with old nvm version. i updated my nvm version and install nodejs, and it worked fine.