Next.js Discord

Discord Forum

Express to Next 13 Question

Unanswered
Wuchang bream posted this in #help-forum
Open in Discord
Avatar
Wuchang breamOP
The docs feels like it is missing some info for Next 13. I just migrated from create-react-app to NextJS, but now I need to migrate my express server to NextJS as well.

For anyone who is familiar with both, do I need to create a new folder for each route and then a new file for each controller function?

So, what would be this in express:
  /
  ├── index.js
  ├── controllers
  │   └── product.js
  └── routes
      └── product.js
  
  controllers/product.js
  ├── getProduct
  └── getAllProducts


Would be this is NextJS:
  ├── app
      └── api
          └── products
              ├── getProduct.js
              └── getAllProducts.js

3 Replies

Avatar
Alfonsus Ardani
Next.js is only conerned about the final routing structure that the user will use.
Regarding the controller folders like /controllers is completely up to you
anything that is inside the app folder (or pages folder) will be used to process the final routing structure of the application
You can still put stuff inside app like app/products/getProduct.js and it wont be read by Next.js since its not a valid Next.js file.