Scalable project structure
Unanswered
Asian black bear posted this in #help-forum
Asian black bearOP
Hello everyone,
I am coming from Angular and the project structure there is a bit more 'pattern' by default because of services, pipes, guards, and interceptors, as we have these components built in.
Usually, I had one API service where the logic for HTTP requests is implemented like get, post, put, and delete.
Besides that, I had services for each feature module, for example, vendors, where all methods for vendors are implemented like getById, getAll, getFiltered,...
After that, I use only a required service injected into a component by dependency injection. In that way, logic is moved out of a component.
I am starting with next js, we are using it only as the frontend application, API will be .NET Core.
Can you please tell me more about your project structure, where u are fetching data, error handling, etc.
We are working on a bit complex application, could you please suggest libraries and APIs that are suggested for large-scale projects?
Like redux, useSWR or standard fetch/Axios, what fake/mock data service are you using?
I started with the app router, but I'm not sure if it's ready for production yet. Maybe I should switch to the page router. I searched a bit about the way of getting an active route from the server component, if am on the right path, we were getting context from getServerSideProps before, where we had a route, now we have to get it from the header.
Would you suggest someone working on a large-scale production-grade project starting with an app router? this is a startup project and we decided to go with next because of pre-rendering like SSR and SSG and SEO optimization.
By the way, This community is great, already got some answers here, thank you!
I am coming from Angular and the project structure there is a bit more 'pattern' by default because of services, pipes, guards, and interceptors, as we have these components built in.
Usually, I had one API service where the logic for HTTP requests is implemented like get, post, put, and delete.
Besides that, I had services for each feature module, for example, vendors, where all methods for vendors are implemented like getById, getAll, getFiltered,...
After that, I use only a required service injected into a component by dependency injection. In that way, logic is moved out of a component.
I am starting with next js, we are using it only as the frontend application, API will be .NET Core.
Can you please tell me more about your project structure, where u are fetching data, error handling, etc.
We are working on a bit complex application, could you please suggest libraries and APIs that are suggested for large-scale projects?
Like redux, useSWR or standard fetch/Axios, what fake/mock data service are you using?
I started with the app router, but I'm not sure if it's ready for production yet. Maybe I should switch to the page router. I searched a bit about the way of getting an active route from the server component, if am on the right path, we were getting context from getServerSideProps before, where we had a route, now we have to get it from the header.
Would you suggest someone working on a large-scale production-grade project starting with an app router? this is a startup project and we decided to go with next because of pre-rendering like SSR and SSG and SEO optimization.
By the way, This community is great, already got some answers here, thank you!
12 Replies
app router is production ready and has been for a while
ssr paths dont need to be ascertained because you made the path so you know the route
ssr fetch. never axios
redux is built to solve a problem with client only applications.
think that covers it
@DirtyCajunRice | AppDir ssr paths dont need to be ascertained because you made the path so you know the route
Asian black bearOP
but SSR is supported for dynamic routes too, right? What is the alternative for gSSP(context) in the current app router?
@Asian black bear but SSR is supported for dynamic routes too, right? What is the alternative for gSSP(context) in the current app router?
dynamic routes have params that give you the missing parts.
@DirtyCajunRice | AppDir dynamic routes have params that give you the missing parts.
Asian black bearOP
yep, you are right, just found it.
https://nextjs.org/docs/app/api-reference/file-conventions/layout#params-optional
thanks!
https://nextjs.org/docs/app/api-reference/file-conventions/layout#params-optional
thanks!
Asian black bearOP
@joulev can we leave this open as I asked for multiple answers, like discussion?
i removed it as OP requested, Lmk if i shouldn't do that
@Asian black bear <@484037068239142956> can we leave this open as I asked for multiple answers, like discussion?
It’s always open, as long as it’s not locked (which we won’t do unless things here get too bad). Feel free to mark any messages as answer
Asian black bearOP