NextJS folder structure for back end?
Unanswered
Schweizer Laufhund posted this in #help-forum
Schweizer LaufhundOP
First time using Next for backend, I usually use Node/Express.
I'm planning on implementing auth to my applications and some api calls between my front and backend but I'm not sure how to structure my folders for a backend application
This is my current folder structure for my frontend.
Is there something about this on next docs? i couldnt find anything on how to use nextjs for backend besides stuff about server actions
I'm planning on implementing auth to my applications and some api calls between my front and backend but I'm not sure how to structure my folders for a backend application
This is my current folder structure for my frontend.
Is there something about this on next docs? i couldnt find anything on how to use nextjs for backend besides stuff about server actions
12 Replies
Schweizer LaufhundOP
Also when would i use api routes vs server actions?
@Schweizer Laufhund Also when would i use api routes vs server actions?
server actions let u call serverside code without exposing a api route
just like php
but without reloading the page because the route just reloads the serverside data
actions in a seperate folder called "actions"
like this
@gin server actions let u call serverside code without exposing a api route
Schweizer LaufhundOP
so unless i want to make a public api route i should just use server actions to make calls to my backend/database?
@Schweizer Laufhund so unless i want to make a public api route i should just use server actions to make calls to my backend/database?
yes but u will need api routes also... using server actions for things like login, usw or just revalidating and filling data without mutating ur current state
Schweizer LaufhundOP
i see
@gin yes but u will need api routes also... using server actions for things like login, usw or just revalidating and filling data without mutating ur current state
Schweizer LaufhundOP
im thinking of using Lucia for auth so hopefully it works well with next