#Login with Next-auth and FormData
1 messages · Page 1 of 1 (latest)
Based on the information provided in the extracts, here's an example of how you can get FormData in HTML <form></form> tags using 'use client' in Next.js:
'use client'
import { useState } from 'react'
import { handleSubmit } from './actions.js'
export default function ExampleClientComponent({ myAction }) {
const [input, setInput] = useState()
return (
<form action={handleSubmit} onChange={(e) => setInput(e.target.value)}>
{/* ... */}
</form>
)
}
In this example, the useState hook is used to manage the form data. The onChange event handler updates the state with the form data every time the form input changes. The handleSubmit function, which is imported from './actions.js', is used as the form's action. This function would handle the form submission.
However, the extracts do not provide information on how to log in with Next-Auth. For that, you may want to refer to the Next-Auth documentation (https://next-auth.js.org/getting-started/introduction) or other relevant resources.
Sources:
- Next.js > app > building-your-application > data-fetching > server-actions > Server Actions > Convention > Enhancements > Progressive Enhancement (https://nextjs.org/docs/app/building-your-application/data-fetching/server-actions)