Skip to content
Discussion options

You must be logged in to vote

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

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:

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…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by enkicoma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants