Next.js Discord

Discord Forum

What's the difference between /pages/test.tsx and /app/test/page.tsx

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
Hello, as per title. I'm reading the docs and in the tutorial the suggested way to create a route is to create a folder with that name in the app folder and then add a page.tsx in it. I did it and it works, however when reading the doc for dynamic routes, it says to create a folder pages, then add a folder with the name of the route and finally a [slug].tsx in it.

* When trying to do dynamic routes /app/test/[id].tsx doesn't work and returns a 404, /pages/test/[id].tsx works and /pages/test/[id]/page.tsx is reachable but it complains about next/router being used serverside
* When doing static routes both /app/test/page.tsx and /pages/test.tsx work without issues

I'm assuming the difference here is server vs. client-side rendering. Is there some documentation that explains the difference between /app and /pages? What is the recommended project structure to avoid mixing stuff?

1 Reply

Brown bearOP
Nevermind, I think I was reading old documentation and /pages is deprecated in favor of /app routing. Please correct me if I'm wrong, thanks!