I want to make a form that can POST some data to my backend. Is adding a new API route reasonable?
Answered
Saltwater Crocodile posted this in #help-forum
Saltwater CrocodileOP
I don't want to use form actions or whatever the new thing is called.
Given that, is create a new POST / PUT / whatever API route a reasonable default? That is what I'm doing as of right now, but as a (mainly) backend developer it feels a bit weird to me to have this backend "API" route inside of my Next.js app. At the same time, it seems perfectly workable, and is infact working currently. I'm just wondering if there is a different option, within the Next.js world, to create a backend to make client side requests to (e.g. for form submissions).
Thank you!
Given that, is create a new POST / PUT / whatever API route a reasonable default? That is what I'm doing as of right now, but as a (mainly) backend developer it feels a bit weird to me to have this backend "API" route inside of my Next.js app. At the same time, it seems perfectly workable, and is infact working currently. I'm just wondering if there is a different option, within the Next.js world, to create a backend to make client side requests to (e.g. for form submissions).
Thank you!
Answered by riský
without server actions, the only way of handling a POST request is from route handlers (an api route effectively) - pages dir just calls if api route
2 Replies
without server actions, the only way of handling a POST request is from route handlers (an api route effectively) - pages dir just calls if api route
Answer
Saltwater CrocodileOP
Thank you very much!