I am new to web development and to Next js. I want to know what is the best way to structure. Like we keep pages in /pages directory and /static, /components.
So where i can keep my code related to validation, some business logic etc
I like having a utils directory for utility functions/classes that I use in multiple places. Validation might or might not fall within this. If validation is specific to a component, I think would want it to exist in that component.
I also like having a api directory that has any code related to fetching data from an api.
Right. I personally have the following directories for my personal site: components, containers, pages, styles, and static. All of my configuration files exist at the root. This particular project is a static site, so it doesn't really have business logic but if it did I'd probably have an api directory. If Ii had reusable functions, I'd have them in a utils directory (I've seen libs for this as well). In short, I've arranged my file structure how it best works for me and I haven't had any problems.
Diego Bernal
Front-End Engineer
I like having a
utilsdirectory for utility functions/classes that I use in multiple places. Validation might or might not fall within this. If validation is specific to a component, I think would want it to exist in that component.I also like having a
apidirectory that has any code related to fetching data from an api.