Next.js Discord

Discord Forum

best way to add toast in server action form

Unanswered
Thrianta posted this in #help-forum
Open in Discord
ThriantaOP
i made my component as a server side page. only i have to add toast here.but most of the toast liabary needs client to run.i dont want to make my full page client . is there any way to add toast without making component client?. (if needed i can make another client component for toast no problem on that)

5 Replies

Technically you can avoid all “use client” by executing the action then redirect to /the-same-page?message=Success, then in the server component check for the message searchParams and render a banner if needed
But I wouldn’t recommend that. Use client components where you should
Pacific saury
@sabin so for every form there in my app I need to create client components?
Yes, if you need it to behave like this