Next.js Discord

Discord Forum

Can't see /something route

Answered
Say's Phoebe posted this in #help-forum
Open in Discord
Say's PhoebeOP
I have added /something route in the src directory, but it is showing 404 at /something route
Answered by B33fb0n3
first choose which router you really want to use:
1. app router (app/)
2. pages router (pages/)

The app router is newer and easier to learn so I tell you how you do it via the app router:
inside your app/ folder, create a folder something and inside that folder, create a file called page.tsx. Then add the following to the file:
export default async function Page({}: {}) {
  return <p>Hello World!</p>
}

Delete the pages/ folder and it should work correctly. If needed create a new project via: npx create-next-app@latest and choose that you want to use the app router
View full answer

3 Replies

@Say's Phoebe I have added /something route in the src directory, but it is showing 404 at /something route
first choose which router you really want to use:
1. app router (app/)
2. pages router (pages/)

The app router is newer and easier to learn so I tell you how you do it via the app router:
inside your app/ folder, create a folder something and inside that folder, create a file called page.tsx. Then add the following to the file:
export default async function Page({}: {}) {
  return <p>Hello World!</p>
}

Delete the pages/ folder and it should work correctly. If needed create a new project via: npx create-next-app@latest and choose that you want to use the app router
Answer
Say's PhoebeOP
thanks a lot
happy to help