I have a next.js application as a portfolio project.
there is an index.js inside of a pages directory that functions as an app.js would in a normal react application… the components folder holds all of my components that im using.
I would like each item on the main menu in the header section to be its own route, so i would like the buttons in the header to lead to an ‘/intro’ ‘/about’ ‘/contact’ etc… (currently each is just its own seperate component in the components folder and does not belong to any route)
what I did:
I moved intro component out of the components and into the /pages folder
I added a link to /intro on the intro button in the header
"If you create pages/about.js that exports a React component like below, it will be accessible at /about "
yet ive created a pages/intro that exports the Intro component yet it crashes. Next.js version "next": "^10.0.5",
What am i doing incorrectly? it is some issue with webpack?
the project you forked has its last commit made on Sep 22, 2018 with NextJS 7. I even can’t run npm install without some errors that break the installation.
Because your ideas are correct, meaning:
create a file pages/intro.js
create a Link to /intro
, I highly recommend creating a new NextJS app from scratch and add the stuff from your current project.
I know that this seems to be a little bit of work, but I think it will highly increase the simplicity of your future work on this project.
Yet it has been updated to the latest version of next.js, I had to do that in order to deploy it… I hear what you are saying but Im not experienced with Next.js, ive not been trained in it… I fear I dont have the confidence nor the support to try that approach. Thank you for your reply.
its the same result, whether the method is there or not, still an empty page.
Yes I realize what your saying:
i.e. that the route does work but how can i fix it? obviously I want it to look and behave the same as it did before…
can you please provide a bit more advice. thank you for your reply.
I think im closer now to the answer but I still dont know… I see this in the documentation but im not sure exacactly how It wants me to implement it in my current project:
ive renamed index.js to _app.js and in package.json ive set main to _app.js
now its changing the route without loosing the styles but… still not quite as intended… also I noticed this in the console but Im not sure if it has any significance, just thought i should point it out: