Next.js Discord

Discord Forum

Server action respond

Unanswered
Collared Plover posted this in #help-forum
Open in Discord
Collared PloverOP
Hi, I would like to know, is it possible to communicate a respond back to the client component after a server action:

// Action.js
'use server'

export async function handleSubmit(formData) {
    console.log(formData.get('test'));

    return console.log('works');
}


// page.js
'use client'

import { handleSubmit } from "./Action"

export default function Autheticate(){

    return(
        <form action={handleSubmit}>
            <input name="test" />
            <button type="submit">Test</button>
        </form>
    )
}

1 Reply