nextjs navbar example
nextjsHere’s an example of a navbar component that you can use in your Next.js application:
import Link from 'next/link'
function Navbar() {
return (
<nav>
<ul>
<li>
<Link href="/">
<a>Home</a>
</Link>
</li>
<li>
<Link href="/about">
<a>About</a>
</Link>
</li>
<li>
<Link href="/contact">
<a>Contact</a>
</Link>
</li>
</ul>
</nav>
)
}
export default Navbar
To use this navbar in a page, you can import it and render it like this:
import Navbar from '../components/Navbar'
function Page() {
return (
<div>
<Navbar />
{/* Page content goes here */}
</div>
)
}
export default Page
Note that the Link component is used to create the links in the navbar. This component is provided by Next.js and allows you to create client-side routes in your application.
Other Article on Tag nextjs
- - fetch function mode sors, no-cors, same-origin
- - fetch request option
- - How to add Bootstrap in Next.js
- - how to minimize front in next js
- - nextjs add bootstrap
- - nextjs add Font Awesome
- - nextjs add font face in head
- - nextjs add prismjs
- - nextjs add Syntax highlighting code
- - nextjs call api