---
title: Show available variants
description: Show available variants as links within a product form.
source_url:
html: https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector
md: https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector.md
---
ExpandOn this page
* [Requirements](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector#requirements)
* [Selecting Variants with Links](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector#selecting-variants-with-links)
* [Query the Storefront API for Product Options](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector#query-the-storefront-api-for-product-options)
* [Variant​Selector component](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector#variantselector-component)
* [Calculating the selected product](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector#calculating-the-selected-product)
* [Product Variants by Availability](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector#product-variants-by-availability)
* [Add to cart](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector#add-to-cart)
* [Automatically select a default variant](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector#automatically-select-a-default-variant)
* [Next steps](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/variant-selector#next-steps)
# Show available variants
This guide shows you how to render a product form that includes a list of available product variants.
***
## Requirements
* You've completed the [quickstart guide](https://shopify.dev/docs/storefronts/headless/hydrogen/getting-started).
* You've [set up a cart handler](https://shopify.dev/docs/storefronts/headless/hydrogen/cart/setup).
***
## Selecting Variants with Links
Many product pages include a form where options are submitted to the server when the user adds to the cart. The most basic product form enables customers to select from available variants. For example, variants might include product size and color.

In Hydrogen we recommend using a `Link` to select each variant. This automatically updates the URL when customers select a variant, which has the following benefits:
* Search engines can easily index each separate variant.
* Users can share and bookmark each separate variant.
* Variants can be prefetched on hover, which decreases the perceived load time.
***
## Query the Storefront API for Product Options
First, your product query needs to include product options. Do this by adding `options` with the `name` and `optionValues` properties:
## JavaScript
routes/products.$handle.jsx
```jsx
export async function loader({ request, params }) {
const { product } = await context.storefront.query(PRODUCT_QUERY, {
variables: {
handle: params.productHandle,
},
});
return json({ product });
}
const PRODUCT_QUERY = `#graphql
query Product(
$handle: String!
) {
product(handle: $handle) {
id
title
vendor
handle
descriptionHtml
description
options {
name
optionValues {
name
}
}
media(first: 7) {
nodes {
...Media
}
}
seo {
description
title
}
}
}
`;
```
***
## Variant​Selector component
Now that you've queried product options, you can use the `VariantSelector` component to render links for all product options:
## JavaScript
routes/products.$handle.jsx
```jsx
import { VariantSelector } from "@shopify/hydrogen";
const ProductForm = ({ product }) => {
return (
{({ option }) => (
<>