Versioning for web components
The Polaris web component library is versioned. Choose the release your app loads and control when your app moves to a new version. This reference documents Polaris 1.1.
For production, we recommend the stable channel, polaris-1.js. It always serves the newest stable release in Polaris 1, so bug fixes, accessibility improvements, and new components reach your app without a script-tag change.
Anchor to Adding Polaris to your appAdding Polaris to your app
You can pin any app to a particular version of the Polaris web component library, but the method you use depends on how you built it.
The snippets below load the stable channel, polaris-1.js. Only name a specific release, like polaris-1.1.js, if you need to lock your app to exactly Polaris 1.1. To learn more, see Stable releases and release candidates.
HTML
To add Polaris to an app built with any framework, add the following script tags to your app's HTML head. Load App Bridge alongside Polaris: App Bridge connects your app to Shopify admin, and the shopify-api-key meta tag tells it which app is loading.
HTML
<head>
<meta name="shopify-api-key" content="%SHOPIFY_API_KEY%" />
<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js"></script>
<script src="https://cdn.shopify.com/shopifycloud/polaris-1.js"></script>
</head>Remix
// app/root.tsx
export default function App() {
return (
<html>
<head>
<meta name="shopify-api-key" content="%SHOPIFY_API_KEY%" />
<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js" />
<script src="https://cdn.shopify.com/shopifycloud/polaris-1.js" />
</head>
</html>
);
}App Bridge isn't versioned with Polaris, so its script tag has no version in the URL and always loads the latest App Bridge. To learn what App Bridge provides, see App Bridge APIs.
React Router template
When you scaffold your app using Shopify CLI, Polaris is added to your app automatically. Which release your app loads by default depends on its version of @shopify/shopify-app-react-router.
The AppProvider component from @shopify/shopify-app-react-router renders the App Bridge and Polaris script tags for the routes that it wraps, and your app's document responses carry a Link header that preloads the Polaris script. Set the release you want in both places, and keep them the same: if they disagree, the browser downloads a file your app never runs.
The examples use the file names of the TypeScript template. In the JavaScript template, the same files end in .jsx instead of .tsx and .js instead of .ts, like app/routes/app.jsx and app/shopify.server.js.
React Router
// app/routes/app.tsx
<AppProvider
apiKey={apiKey}
polarisUrl="https://cdn.shopify.com/shopifycloud/polaris-1.js"
>
<Outlet />
</AppProvider>Server configuration
// app/shopify.server.ts
const shopify = shopifyApp({
// ...
polarisUrl: 'https://cdn.shopify.com/shopifycloud/polaris-1.js',
});Both options are optional, and they require @shopify/shopify-app-react-router 2.1.0 or later. If you set neither, then the default depends on the package's major version. In versions 2.1.0 to 3.x, both default to the unversioned polaris.js entry point. In version 4.0.0 and later, both default to polaris-2.js, which never serves Polaris 1. To stay on Polaris 1 with version 4.0.0 or later, set both options, as the snippets show. To learn which release each entry point serves, see Available versions. To learn when the default changed, see the @shopify/shopify-app-react-router changelog.
Some versions of the template also load Polaris on the login page, app/routes/auth.login/route.tsx (route.jsx in the JavaScript template), with a script tag or an AppProvider of its own. polarisUrl in app/routes/app.tsx doesn't apply to that page, so the login page can load a different release from the rest of your app. If your app has this route, then load Polaris there with a script tag that uses the same URL as polarisUrl. The login page is a separate document from the routes that AppProvider wraps, so this tag doesn't load a second bundle. Don't use AppProvider on the login page: from version 2.0.0, it always loads App Bridge too, and the login page opens outside the Shopify admin.
To add Polaris to an app built with any framework, add the following script tags to your app's HTML head. Load App Bridge alongside Polaris: App Bridge connects your app to Shopify admin, and the shopify-api-key meta tag tells it which app is loading.
HTML
<head>
<meta name="shopify-api-key" content="%SHOPIFY_API_KEY%" />
<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js"></script>
<script src="https://cdn.shopify.com/shopifycloud/polaris-1.js"></script>
</head>Remix
// app/root.tsx
export default function App() {
return (
<html>
<head>
<meta name="shopify-api-key" content="%SHOPIFY_API_KEY%" />
<script src="https://cdn.shopify.com/shopifycloud/app-bridge.js" />
<script src="https://cdn.shopify.com/shopifycloud/polaris-1.js" />
</head>
</html>
);
}App Bridge isn't versioned with Polaris, so its script tag has no version in the URL and always loads the latest App Bridge. To learn what App Bridge provides, see App Bridge APIs.
Anchor to TypeScript packagesType Script packages
For TypeScript users, Shopify publishes the @shopify/polaris-types package. Match the package version to the release your app loads, so that your types describe the components your app actually renders.
If you load polaris-1.js, install @shopify/polaris-types@^1.1.0. If you load polaris-1.1.js, install @shopify/polaris-types@~1.1.0, so the package stays on 1.1 like the script tag.
For reproducible installs, pin the exact version instead. Update the script tag and the package together when you move to a new release.
Anchor to Available versionsAvailable versions
The following table shows the different options for configuring your script tag and the version of the library that is served. For production, we recommend the stable channel, polaris-1.js.
| Script tag | Serves | Notes |
|---|---|---|
polaris-1.js | The newest stable release in Polaris 1 | Advances each time a new 1.x release goes stable |
polaris-1.1.js | Polaris 1.1 | Frozen as released |
polaris-1.0.js | Polaris 1.0 | Frozen as released |
polaris.js | The legacy unversioned entry point, which serves the newest stable release in Polaris 1 | Advances with each new stable 1.x release |
Anchor to Stable releases and release candidatesStable releases and release candidates
Each stable release is also published at its own URL, like polaris-1.0.js and polaris-1.1.js. Published stable versions are immutable except for critical security fixes, ensuring that your app continues using the version of the library you tested against. If you need to control exactly when your app moves, name a specific version instead of the channel.
Promotion doesn't update the release candidate URL in place. The stable release publishes at its own URL instead, so moving to it is a change you make in your app's code: update the script tag to polaris-1.1.js for that release, or to polaris-1.js to follow the channel.
Anchor to Check which version your app loadsCheck which version your app loads
A channel, like polaris-1.js, or the unversioned polaris.js doesn't show which release it serves. To check the script that your app loads and the release that it runs, open your app in the Shopify admin, and then open your browser's developer tools:
- In the Network panel, filter the requests by
polaris. The file name in the request URL is the script that your app loads, likepolaris-1.js. If your app also loads Polaris on a page outside the Shopify admin, such as a login page, then open that page and check it too. - In the Console panel, select your app's frame as the JavaScript context, and then run
polaris.version. The result is the exact release that your app runs, like"1.1.0".
The @shopify/polaris-types version can be different from this result. The types package publishes a new version only when the types change, so a release can have no types package with the same version. To pin your types, install the newest published @shopify/polaris-types version on the same release line.