DEV Community

Discussion on: How I structure my mid-size NextJs projects

Collapse
josemukorivo profile image
Joseph Mukorivo Author

Seems to be maintainable, but how do you deal with shared and small components like buttons?

Collapse
hisuwh profile image
Henry Ing-Simmons

As Robin has alluded to you can have a common folder. I in fact have a fairly large common folder, broken down into sub-features - e.g. common/buttons. I also don't like the index.js approach as someone else has mentioned so I would have common/buttons/SaveButton.js, common/buttons/CancelButton.js etc. Then one index.js file in buttons to export these.

For common you can even then add a webpack alias so you can import these from anywhere without lots of ../../, e.g. import { SaveButton } from "@common/buttons";