Next.js Discord

Discord Forum

use server

Unanswered
Brown bear posted this in #help-forum
Open in Discord
Brown bearOP
this function in server side can i return something to client side like this one ?


"use server" export async function funForm(formData) { return ( <div className="alert"> <span>We have received your fun form !! .</span> </div> ) }

by the way how to use code inside discord ?

4 Replies

No, currently you can’t return components from server actions
Consider making a route handler and display the result or error with libraries like React Query
@fuma Consider making a route handler and display the result or error with libraries like React Query
Brown bearOP
export async function funForm(formData) { const toClientSide = { message: "We have received your fun form !! ", }; return toClientSide; }
//

works with me
Yes, but you can’t return any react components for now. Seems like you have solved your problem?