I want to redirect the customer to a specific URL after they log in.
Is this possible using either the Theme App Extension or the Customer Account UI Extension?
Hi Remy,
The answer to this depends on the type of customer accounts being used on the shop.
Customer accounts:
You can utilize {{ routes.storefront_login_url }} of the routes Liquid object in either a Theme App Extension or the theme itself if you just want to send the customer back to the storefront where they pressed the login button.
If wanting to send them elsewhere, you can use a Customer Account UI Extension and the Navigation API. I recommend including this redirection based on user action as there isn’t a reliable way to determine if the customer just logged in.
Legacy customer accounts:
You can utilize the return_to form parameter on the account login form. This can be achieved through a Theme App Extension or the theme.
You also have the option to use the usual JS approach with window.location.href in a Theme App Extension or the theme. But again, there isn’t a reliable way to tell if the customer just logged in.
Hope that helps, let me know if you have any questions!