set searchParams in actions
Answered
Chausie posted this in #help-forum
ChausieOP
I need to set searchParams in server actions and I saw a lot of people asking for the same so it is obviously needed, is it possible and if yes how? If not why not?
6 Replies
you can set them by redirecting the client to it. And yes you need a client, because a server actions runs on the server and the server don't know states. So return for example the redirect url (with the searchparams) and after your server actions is complete redirect the client to the new url @Chausie
@B33fb0n3 you can set them by redirecting the client to it. And yes you need a client, because a server actions runs on the server and the server don't know states. So return for example the redirect url (with the searchparams) and after your server actions is complete redirect the client to the new url <@330052695132209162>
ChausieOP
That makes sense, didn't think of it. Thanks! Any idea why I do not get type inference
searchParams object from the props?no idea without seeing the code 

ChausieOP
usually in previous projects I got
searchParams sugguested by the next envoirment, but now in this one not. export default function Home({ searchParams }: any) {
//...
} I do not really know what type it is.try it like this:
export default function Home({
searchParams,
}: {
searchParams: { [key: string]: string | string[] | undefined }
}) {
// ...
}please mark solution
Answer