---
title: getSelectedProductOptions
description: The getSelectedProductOptions returns the selected options from the Request search parameters.
api_version: 2026-04
api_name: hydrogen
source_url:
  html: https://shopify.dev/docs/api/hydrogen/2024-07/utilities/getselectedproductoptions
  md: https://shopify.dev/docs/api/hydrogen/2024-07/utilities/getselectedproductoptions.md
---

# getSelectedProductOptions

The `getSelectedProductOptions` returns the selected options from the Request search parameters. The selected options can then be easily passed to your GraphQL query with [`variantBySelectedOptions`](https://shopify.dev/docs/api/storefront/2026-01/objects/product#field-product-variantbyselectedoptions).

## Props(**[request](#props-propertydetail-request)**​)

A function type that extracts selected product options from a Request's search parameters.

### Parameters

* **request**

  **Request**

  **required**

### Returns

* **SelectedOptionInput\[]**

Examples

### Examples

* #### Example code

  ##### JavaScript

  ```jsx
  import {getSelectedProductOptions} from '@shopify/hydrogen';

  export async function loader({request, params, context}) {
    const selectedOptions = getSelectedProductOptions(request);

    const {product} = await context.storefront.query(PRODUCT_QUERY, {
      variables: {
        handle: params.productHandle,
        selectedOptions,
      },
    });

    return {product};
  }

  const PRODUCT_QUERY = `#graphql
    query Product($handle: String!, $selectedOptions: [SelectedOptionInput!]!) {
      product(handle: $handle) {
        title
        description
        options {
          name
          values
        }
        selectedVariant: variantBySelectedOptions(selectedOptions: $selectedOptions, ignoreUnknownOptions: true, caseInsensitiveMatch: true) {
          ...ProductVariantFragment
        }
      }
    }
  `;
  ```

  ##### TypeScript

  ```tsx
  import {getSelectedProductOptions} from '@shopify/hydrogen';
  import {type LoaderFunctionArgs} from 'react-router';

  export async function loader({request, params, context}: LoaderFunctionArgs) {
    const selectedOptions = getSelectedProductOptions(request);

    const {product} = await context.storefront.query(PRODUCT_QUERY, {
      variables: {
        handle: params.productHandle,
        selectedOptions,
      },
    });

    return {product};
  }

  const PRODUCT_QUERY = `#graphql
    query Product($handle: String!, $selectedOptions: [SelectedOptionInput!]!) {
      product(handle: $handle) {
        title
        description
        options {
          name
          values
        }
        selectedVariant: variantBySelectedOptions(selectedOptions: $selectedOptions, ignoreUnknownOptions: true, caseInsensitiveMatch: true) {
          ...ProductVariantFragment
        }
      }
    }
  `;
  ```

***

## Related

[- VariantSelector](https://shopify.dev/docs/api/hydrogen/2026-04/components/variantselector)

***