useRedirect
The “useRedirect” hook provides a way for the extension to trigger a redirect action to another page.
Usage
const CustomButton = () => { const { redirect } = useRedirect();
const handleClick = () => { redirect("https://www.example.com"); };
return ( <button onClick={handleClick}> My Botton </button> );};
Parameters
The useRedirect
hook does not receive any parameters.
Returns
The useRedirect
hook returns an object with the following properties:
redirect
- type:
redirect: (url: string) => Promise<void>
The url
type is a string that represents the URL to which you want to redirect. It must be a complete URL (e.g., https://www.example.com
).
Extension Points
This hook is available in the following extension points:
punchout.order-summary.cta
For a full list of available extension points, refer to the ExtensionPoints page.