Search code examples
next.jsbuttonmenunextjs14

Is there a way to render a menù on server side and hide it by using a button on client component on nextjs 14 with app router?


I am rendering a menù on server side, like:

    //this is on server
    import Link from 'next/link';
    function Page() {
     return(<nav>
      <Link href="/">Home</Link>
     </nav>
    }

In this case a need a button to show or hide the content, i know i can use 'use client' but i don't want this because googlebot need to crawl static menù. I looked many solutions but nothing works for me. It is comical for advanced framework such nextjs 14.

i tried many solutions but i need something works for what i specified on the title.


Solution

  • Fixed by using after that i retrieve the elemnt with document.getElementById. Classic way on javascript.