useRouter in Next js

  • This hook is use to route between pages. Example:


    "use client"
    import React from 'react'
    import { useRouter } from 'next/navigation';

    const Home = () => {
      const router = useRouter()
      return (
        <div>
          <button
            onClick={() => router.push("/contact")}
          >
            Click
          </button>
        </div>
      )
    }

    export default Home



No comments:

Post a Comment

PHASE 1 — Topic 4: How Socket.IO Works Internally (Engine.IO, Transports, and Fallback)

We now understand what Socket.IO is and why it is useful. In this post, we go one level deeper and look at what actually happens behind the ...