witty-noon-28853
09/22/2025, 9:16 AMchilly-king-10285
09/22/2025, 9:16 AMchilly-king-10285
09/22/2025, 9:16 AMreturn_to
query parameter. This value is then stored in the flow object. In the flow object, the property you are looking for is return_to
. This property tells you where the user should be redirected after a successful login. If you want to create a link or button that takes the user back to the page they visited before being redirected to the login page, you should use the value of flow.return_to
. Here’s how it works: - When you create the login flow, include the return_to
parameter with the URL of the page the user was originally trying to access. - The flow object returned by Ory will contain a return_to
property with this URL. - After a successful login, Ory will redirect the user to the URL specified in return_to
. - If you want to create a manual link (e.g., "Back to previous page"), use the value of flow.return_to
for the link’s destination. Example: js const returnTo = flow.return_to // Use returnTo as the href for your "Back" link or button
Important: - The return_to
URL must be allow-listed in your Ory configuration to prevent open redirect attacks. - If the return_to
property is not set, Ory will use the default redirect URL configured for your project. References: - [Advanced redirects: flow.return_to](https://www.ory.sh/docs/kratos/bring-your-own-ui/custom-ui-advanced-integration) - [Redirection and return_to parameter](https://www.ory.sh/docs/kratos/concepts/browser-redirect-flow-completion#redirection)