Documentation
Feedback
Guides

useRedirect hook

This feature is only available for stores using B2B Buyer Portal, which is currently available to selected accounts.

The useRedirect hook allows an extension to redirect the user to another page.

This hook is only available in some extension points.

Usage


_13
const CustomButton = () => {
_13
const { redirect } = useRedirect();
_13
_13
const handleClick = () => {
_13
redirect("https://www.example.com");
_13
};
_13
_13
return (
_13
<button onClick={handleClick}>
_13
My Button
_13
</button>
_13
);
_13
};

Parameters

The useRedirect hook does not accept any parameters.

Returns

The useRedirect hook returns an object with the following property:

  • redirect: (url: string) => Promise<void>

The url is the destination URL. It must be a complete URL, such as https://www.example.com.

Extension Points

This hook is available in the following extension point:

  • punchout.order-summary.cta
Contributors
2
Photo of the contributor
Photo of the contributor
Was this helpful?
Yes
No
Suggest Edits (GitHub)
Contributors
2
Photo of the contributor
Photo of the contributor
Was this helpful?
Suggest edits (GitHub)
On this page