Add a Manage account action that opens the Kinde portal.
Account settings
Kinde · Module
generatePortalUrl creates a URL for the Kinde portal. In the React SDK, await the result and navigate to its url value, optionally supplying a return path.
Call generatePortalUrl through the useKindeAuth hook to create a portal destination. Await the result, convert its url value to a string, and assign it to window.location.href to send the user to the portal; PortalLink is an alternative that performs the redirect for you.
const { url } = await generatePortalUrl({ returnPath: "/dashboard" });| Name | Type | Description |
|---|---|---|
returnPath | string | Optional path used as the return destination after the portal flow. |
A promise resolving to an object containing url, the generated portal URL.
const { generatePortalUrl } = useKindeAuth();
async function openPortal() {
const { url } = await generatePortalUrl({ returnPath: "/dashboard" });
window.location.href = url.toString();
}
<button onClick={openPortal} type="button">
Manage account
</button>Generates a portal URL with an optional return path, then navigates the browser to that URL.
Account settings
Custom navigation
Return routing
generatePortalUrl is accessed from useKindeAuth and returns a promise. The resolved object contains url, which can be converted to a string and assigned to window.location.href.
Follow-up: How could the same flow be implemented without manually handling the URL? Use the PortalLink component, which generates the link and redirects the user.
Pass an options object containing returnPath, such as { returnPath: "/dashboard" }. This tells the portal flow where the user should return in the application.
Follow-up: What should be checked if the return navigation is wrong? Verify that the supplied path matches the intended application route and that the resulting URL is used for navigation.
After awaiting generatePortalUrl, read the returned url property and navigate with window.location.href = url.toString(). This performs a full browser navigation to the generated portal URL.
Follow-up: What alternative UI abstraction is documented for this purpose? PortalLink can be rendered directly and handles portal redirection without the explicit event handler.
PortalLinkuseKindeAuthself-serve portal