Skip to main content

useSelectedOptionInUrlParam
utility

Sets the url params to the selected option.

Was this section helpful?

Example

useSelectedOptionInUrlParam example

import {useSelectedOptionInUrlParam} from '@shopify/hydrogen';

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

useSelectedOptionInUrlParam(selectedOption);

// URL will be updated to <original product url>?Color=Red&Size=Medium