Redirect to the plan selection page
A common pattern is to redirect merchants to your plan selection page after they install your app. However, because embedded apps are rendered in the Shopify admin inside an iframe, they don’t have permission to manipulate the parent browser window, including redirects.
Shopify's React Router package provides utilities that allow apps to redirect elsewhere in the Shopify admin. This ensures a smoother, more seamless user experience while working within iframe constraints.
Anchor to RequirementsRequirements
- An embedded app scaffolded with React Router. This includes the @shopify/shopify-app-react-router package by default.
- Your app needs to have Managed Pricing enabled, with at least one plan configured.
Anchor to Check subscription status in React RouterCheck subscription status in React Router
The example code in this section demonstrates the basic steps required to implement this behavior in a React Router app:
- Check if the logged-in user has an active app subscription.
- If not, then redirect to the plan selection page.
- If there is an active subscription, then render your app’s content normally.
The @shopify/shopify-app-react-router package includes built-in utilities for handling billing queries and redirects. You can use these utilities in your React Router loaders to check the user’s plan subscription status and redirect if needed.
In this example, the subscription plan check runs at the app's root route, so it works no matter which app route the user arrives at.
The redirect uses the web URL for the plan selection page, which requires both the store handle and your app handle. The store handle is dynamic and should be extracted from the shop domain (for example, "cool-shop" from "cool-shop.myshopify.com"). The app handle is defined in your shopify.app.toml file.
Anchor to Next StepsNext Steps
- Learn more about Managed Pricing