Nextjs Componnents Routing #16886
-
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Hi @enkicoma. Here is how you could layout your application instead:
export default function MyApp({ Component, pageProps }) {
return (
<div>
<Header /> {/* this will be present on every single page */}
<Component {...pageProps} />
</div>
)
} and your components would actually be pages:
and then to link to each of those pages, you would use I'd also recommend checking out the pages documentation which does a better job explaining how this works. |
Beta Was this translation helpful? Give feedback.
Hi @enkicoma.
next/link
(the<Link>
) component is not meant to wrap components, instead you can think of it like an<a href="">
tag.Here is how you could layout your application instead:
pages/_app.js
and your components would actually be pages:
pages/index.js
pages/blog.js
pages/contact.js
pages/about.js
pages/login.js
and then to link to each of those pages, you would use
next/link
:<Link href="/contact"><a>my link to the contact page</a></Link>
and then you could do the same for all other…