Next.js Discord

Discord Forum

passing data from form to "use server"

Answered
American Shorthair posted this in #help-forum
Open in Discord
Avatar
American ShorthairOP
How can i pass custom data from form to the server action
Image
Answered by rphlmr 🫡
<button name='guildId' value={guild.id} type='submit' />

😄
View full answer

10 Replies

Avatar
American ShorthairOP
i want to pass that guild.id
so i can add it to the cookies in the server action
ping when reply please
Avatar
@American Shorthair with the code you show, you can add:

<input name='guildId' value={guild.id} type='hidden' />


in your form
you should see it in your console.log
there is also a quicker way
Avatar
<button name='guildId' value={guild.id} type='submit' />

😄
Answer
Avatar
American ShorthairOP
Thanks alot
Avatar
100% legit too when you want to attach a value to an action button
Avatar
American ShorthairOP
So anyone can just use this to use my server action?
Image