Handle POST data in app router pages (not routes)
Unanswered
Silver posted this in #help-forum
SilverOP
So my idea is to handle form data with SSR components as opposed to an API route in able to avoid CSR entirely (basically the way forms used to be done in the PHP days). I know this isn't how things are done now, but I think it could be useful for ultra-lightweight clients.
* Can app router pages take POST requests?
* Can it handle
* Is there any concept of user sessions or anything like this that can be leveraged?
* Can app router pages take POST requests?
* Can it handle
multipart/form-data (as opposed to application/json)* Is there any concept of user sessions or anything like this that can be leveraged?
6 Replies
SilverOP
So I'm looking at https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions-and-mutations
And the closest thing to this was
It seems that a server side action can indeed take the POST data and use it to do stuff, however, how do I then expose that data to the SSR component instead of just mutating something?
And the closest thing to this was
useActionState, however this requires CSR.It seems that a server side action can indeed take the POST data and use it to do stuff, however, how do I then expose that data to the SSR component instead of just mutating something?
SilverOP
I guess something like
headers() for the request itself or at least the body of it?I am almost sure what you are gonna do is accurate
I wonder why you need your app router pages take POST requests
as you said, server actions are good enough to take POST request
and then instead of exposing that data to the SSR component, you need to revalidate to purdge the cache