ForgotPasswordForm Section
Updated over a week ago

Customers can reset their password via the account dashboard, but they need to be logged in for that to happen. If they forgot their password, they can request a reset password link. To handle this use case, let's create a new section:

  1. On your local environment, create a new folder inside src/sections and name it as ForgotPasswordForm.

  2. Create an index.js file inside the ForgotPasswordForm folder.

  3. Create a styles.module.css file inside the ForgotPasswordForm folder.

import React from 'react'
import { useCustomerActions } from 'frontend-customer'
import Link from 'frontend-link'
import AuthGuard from 'Components/AuthGuard'

const ForgotPasswordForm = () => {
const [inputValue, setInputValue] = React.useState('')
const [submitSuccess, setSubmitSuccess] = React.useState(false)
const [submitErrors, setSubmitErrors] = React.useState()
const [submitInProgress, setSubmitInProgress] = React.useState(false)

const { recoverPassword } = useCustomerActions()

const handleSubmit = async event => {


const { errors } = await recoverPassword(inputValue)

if (errors) {
console.error('Something went wrong', errors)



const disableLoginButton = !inputValue || submitInProgress

return (
{submitSuccess ? (
<h1>Check your inbox!</h1>
<p>We've just sent you an email - follow the reset instructions to change your password.</p>
) : (
<h1>Forgot password</h1>

<AuthGuard allowedAuthStatus="unauthenticated" redirectUrl="/account">
<p>Enter your email and we will send you a password reset link.</p>
<form onSubmit={handleSubmit}>
onChange={(event) => setInputValue(}
<button type="submit" disabled={disableLoginButton}>
<Link href="/account/login">Go back to login</Link>
{submitErrors && (
{, index) => (
<strong key='error-message- + 'index'}>

export default ForgotPasswordForm

Forgot password page

Create the /account/forgot-password page:

  1. Click on the Pages icon from the sidebar.

  2. Click ADD PAGE on the top right corner.

  3. Enter the PAGE NAME: Forgot password.

  4. Enter the PAGE PATH: account/forgot-password.

  5. If you want, you can select a Frame from the Frame dropdown.

  6. Click ADD PAGE.

Now, add the ForgotPasswordForm Section to the Forgot password page (if you are already on the Orders page, skip to step 4):

  1. Click on the Pages icon from the sidebar.

  2. Search for "Forgot password".

  3. Open the "Forgot password" page by clicking on its title.

  4. On the sidebar, click on the + (plus sign) where it says "Add sections to start building your page".

  5. A list with all our Sections will appear; search for and select ForgotPasswordForm.

  6. Click SAVE.

Did this answer your question?