Next.js Discord

Discord Forum

How do I project structure? NextJS docs not helping...

Answered
West African Lion posted this in #help-forum
Open in Discord
West African LionOP
How do I structure my project and place my aws ses files?

- does the api folder go in src, app, or page?
- what are the lib and services folder for?

Just need a bit of clarification to make sense of what is what and where it goes as I'm new to coding and nextjs.

NextJS doc: https://nextjs.org/docs/getting-started/project-structure
Answered by Northeast Congo Lion
src (folder)
  app (folder)
    api (folder)
      ...api routes go inside here (/api)
    ...pages go in here
  components (folder)
    ...components go in here
View full answer

7 Replies

app router is new approach for nextjs and i recommend using it, u can actually use both pages & app together I think, but cleaner to only have one
lib and services just house special functions and such that ur application will use
api goes inside /app/api/... if using app router
West African LionOP
1. I read some articles and answers on stackoverflow where some advice says to keep components inside app while others suggested leaving it outside, in src?

2. does the following make sense?
Northeast Congo Lion
makes perfect sense
Northeast Congo Lion
src (folder)
  app (folder)
    api (folder)
      ...api routes go inside here (/api)
    ...pages go in here
  components (folder)
    ...components go in here
Answer