Add a way to get searchParams in Server Actions #74156
Unanswered
ptvty
asked this question in
App Router
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Related: #50156
Looking at the Network tab I can see that the POST request sent to the server action on form submit already includes all the search params from the current URL, but I couldn't find a way to get them from within the server action function.
There are valid use cases where this is needed.
I'm using a server action as the form action in a pure server component.
The URL already includes multiple search params and I need these params in addition to the form data.
So currently for the server action to have these params I had to get
searchParams
in the server component, and pass them using an<input type="hidden" />
so I can get those in the handler function as the form data.This is obviously not efficient as the same data is present in both the URL and the form data!
Beta Was this translation helpful? Give feedback.
All reactions