Next.js Discord

Discord Forum

App vs Page router: When to use either?

Unanswered
Giant Schnauzer posted this in #help-forum
Open in Discord
Avatar
Giant SchnauzerOP
I know the App router is a relatively new feature. I'm curious, if you were building a web app from the ground up, what scenarios would lend themselves to using the App router vs the Page router? Or is the app router the best way to go for all scenarios?

8 Replies

Avatar
American black bear
i'm confused to choose which one to use for SSG, because i don't intend to use next.js for SSR
Avatar
DirtyCajunRice | AppDir
pages is deprecated. no new features. so app dir is always the suggestion
Avatar
American black bear
does it affect with src ? when npx create-next-apps i opted yes for src folder, and it's now i have src/app/page.tsx which is i think weird

isnt the /src supposed to be root folder ?
Avatar
Tramp ant
yeah its okay
it was set up for you so it should work fine. if youre using tailwind you might need to update content paths
src is just to keep your code separated from configuration files. In it you can have directories for components, hooks, libs, translation and pretty much anything
Avatar
American black bear
how to make the imported style global ? currently i have /app/layout.tsx and /app/page.tsx .. But not sure which one is the entry point / maiin index.tsx since the guide discourage to override the _app.tsx
Avatar
joulev & fuma pray for Schneider
app dir: import the css file to app/layout.tsx

pages dir: import the css file to pages/_app.tsx