8. Address
Collect shipping and billing address on the cart.
On this page
The second step in the express checkout flow is the address details step. In this step, the customer will input their shipping address.
To create the component of this step, create the file components/Address/index.tsx with the following content:

tsx
You create an Address component that receives the product's handle and whether the component is active as props. The component defines the following variables:
cartandupdateCart: The customer's cart and the function to update the cart, retrieved from the cart context.region: The selected region retrieved from the region context.loading: A boolean state variable indicating whether an operation is loading.firstName,lastName,email,phone,address,postalCode,city, andcountry: State variables that hold the customer's shipping and billing address details.router: The router instance to navigate between steps.
Next, you'll define a variable that determines whether the customer can save the address and go to the next step. First, add the following import at the top of the file:
tsx
Then, replace the TODO in the Address component with the following:
tsx
You create an isButtonDisabled memoized variable whose value is a boolean indicating whether the button to go to the next step is disabled.
Implement Submit Action Function
Next, you'll implement the function that will be called when the customer submits their address details.
Replace the TODO in the Address component with the following:
tsx
In the handleSubmit function, if the button isn't disabled, you set loading to true, then use the updateCart function from the cart context to update the cart with the customer's shipping and billing addresses and email.
You can have different forms for billing and shipping addresses.
Once the address is saved, you redirect the customer to the next step in the flow, which is the shipping step.
Render Address Form
Lastly, you'll add the return statement that shows the address form.
First, add the following imports at the top of the file:
tsx
Then, replace the last TODO in the Address component with the following:
tsx
You wrap the address form with the Card component you created earlier. In the card, you show inputs for the address details and a button that, when clicked, executes the handleSubmit function you created earlier.
Add to Router Component
Finally, you'll add the Address component to the Router component to show the address details step.
First, import the Address component at the top of the components/Router/index.tsx file:
tsx
Then, change the return statement of the Router component to the following
tsx
This will show the address details step and expand its details if activeTab is address.
Test it Out
While both the Aiminaabee application and the Aiminaabee Next.js storefront template are running, if you refresh the page you had opened or go to http://localhost:3000/sweatpants?step=address, you should see the address form where you can input your address details.

You can input your address details then click on the "Continue" button. The address will be saved in the cart and the Address card will collapse. The third step's details should be shown, which you'll add next.
Next: 9. Shipping