Next.js Discord

Discord Forum

App Router and a server components.

Unanswered
Black carp posted this in #help-forum
Open in Discord
Black carpOP
So from my own experiments, it's technically possible to have Server Components to contain server logic. Simple, but can we avoid all together a need for an API endpoint in favour of having server logic done on a server component than an endpoint. E.g. Instead of having a /login route I do that within the server component. validation, DB access and auth. Are there any consequences with this approach or any issues with development as I cannot see that by an initial glance

2 Replies

Black carpOP
Just to update: What I'm asking is considering we can use server actions, instead of having an api route why not do all the backend logic in nextjs without calling an endpoint. e.g. create a server component with a server action that lets say updates db values.
American Chinchilla
You can do that.