---
title: mapSelectedProductOptionToObject
description: >-
  Converts the product selected option into an Object&lt;key, value&gt; format
  for building URL query params
api_version: 2026-04
source_url:
  html: >-
    https://shopify.dev/docs/api/hydrogen/latest/utilities/mapselectedproductoptiontoobject
  md: >-
    https://shopify.dev/docs/api/hydrogen/latest/utilities/mapselectedproductoptiontoobject.md
api_name: hydrogen
---

# mapSelectedProductOptionToObject

Converts the product selected option into an `Object<key, value>` format for building URL query params

Examples

### Examples

* ####

  ##### mapSelectedProductOptionToObject example

  ```js
  import {mapSelectedProductOptionToObject} from '@shopify/hydrogen';

  const selectedOption = [
    {
      name: 'Color',
      value: 'Red',
    },
    {
      name: 'Size',
      value: 'Medium',
    },
  ];

  const optionsObject = mapSelectedProductOptionToObject(selectedOption);

  // Output of optionsObject
  // {
  //   Color: 'Red',
  //   Size: 'Medium',
  // }

  const searchParams = new URLSearchParams(optionsObject);
  searchParams.toString(); // '?Color=Red&Size=Medium'
  ```

***

## Related

[- getProductOptions](https://shopify.dev/docs/api/hydrogen/2026-04/utilities/getproductoptions)

[- getAdjacentAndFirstAvailableVariants](https://shopify.dev/docs/api/hydrogen/2026-04/utilities/getadjacentandfirstavailablevariants)

[- useSelectedOptionInUrlParam](https://shopify.dev/docs/api/hydrogen/2026-04/utilities/useselectedoptioninurlparam)

***
