--- url: https://polaris-vue-elements.dev/guide/getting-started.md description: >- Install polaris-vue-elements, load the Shopify Polaris web components runtime, and use typed Vue 3 wrappers like SButton and STextField with v-model in a Vue app or Shopify app. --- # Getting started `polaris-vue-elements` is a set of typed Vue 3 components that wrap Shopify's Polaris web components (``, ``, ``, ...). The web components themselves are loaded at runtime from Shopify's CDN — this library just gives you a typed, idiomatic Vue surface (props, events, v-model) around them. ## 1. Install ```sh npm install polaris-vue-elements ``` ## 2. Load the Polaris runtime The wrapper components are presentational only — they don't ship the actual custom element definitions. Your host app must load Shopify's Polaris runtime script, which registers `` elements globally: ```html
``` This works in any Vue app, not just inside Shopify Admin — the components are plain custom elements and render wherever the script is loaded. `polaris-2.js` is Shopify's stable channel and what we recommend for production. To pin an exact release instead, or to understand how the runtime version relates to this library's version, see [Known quirks & gotchas](./quirks#_5-the-polaris-runtime-is-versioned-on-the-cdn-—-this-library-s-version-is-not-the-runtime-s-version). ### Polaris 2.0 and the new admin design Polaris 2.0 brings the Shopify admin's new visual design (color, typography, spacing and icons). It became stable on October 22, 2026 ([announcement](https://shopify.dev/changelog/posts/polaris-cdn-2-0-is-now-stable)). Moving from 1.x is opt-in: swap `polaris-1.js` for `polaris-2.js`. * **No code changes needed.** 2.0 is a visual update: its components, props, events and slots are the same as 1.1, plus a few additions (such as `SThumbnail`'s `loading` prop). Apps that stay on `polaris-1.js` keep working with these wrappers; only the additions need 2.x at runtime. * **It follows each store's design.** Inside the Shopify admin, a store that has the new admin design gets the new look, and a store on the previous design keeps the 1.x look. Outside the admin, the new look is used by default, which makes it easy to preview locally. * **Fixed or sticky content near the bottom of the viewport** should reserve space with the `--shopify-safe-area-inset-bottom` CSS variable ([environment API](https://shopify.dev/docs/api/app-home/latest/apis/authentication-and-data/environment-api)), so the floating Sidekick bar doesn't cover it. * **Built for Shopify apps** must match the admin's new visual style by **May 1, 2027**. ## 3. Configure Vite Tell Vue's compiler to treat any `s-*` tag as a custom element instead of trying to resolve it as a Vue component: ```ts // vite.config.ts import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' export default defineConfig({ plugins: [ vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.startsWith('s-'), }, }, }), ], }) ``` ## 4. Your first component Import components from `polaris-vue-elements` and use them like any other Vue component — props and events are fully typed: ```vue ``` ## 5. v-model on form components Form-like components support `v-model`, mapped to the correct underlying prop/event pair for that element (see `src/lib/overrides.ts` for the full mapping — text-likes use `value`/`input`, `SCheckbox`/`SSwitch` use `checked`/`change`, `SChoiceList` uses `values`/`change`, and so on): ```vue ``` ## 6. Controlling overlays (modal, popover, tooltip) Overlay components like `SModal` can be controlled two ways: **Declaratively**, with the standard HTML `commandFor`/`command` attributes on a trigger button — no script required: ```vue ``` **Imperatively**, by grabbing a typed template ref and calling the underlying element's method through `$el`: ```vue ``` ## 7. Typing raw `` tags (optional) If you'd rather keep writing Polaris's own tags (``, ``, …) than switch to the wrappers, the package can still type them. Opt in once, in your `tsconfig.json`: ```json { "compilerOptions": { "types": ["polaris-vue-elements/elements"] } } ``` or with a reference in a `.d.ts` file such as `env.d.ts`: ```ts /// ``` This adds every Polaris tag to Vue's `GlobalComponents`, so Volar and `vue-tsc` check raw tags the same way they check the wrappers: union-typed props, typed `@click` / `@aftershow` listeners, and a typed element for imperative methods. ```vue ``` It's types only: nothing is registered at runtime, so keep the `isCustomElement` setting from step 3. Two differences from the wrappers: * **No `v-model` on raw tags.** Bind `:value` and listen for `@input` / `@change` yourself, or use the wrapper component, which maps each form field's property and event for you. * **Don't combine it with a hand-written shim** for the same tags in your project — two declarations of `GlobalComponents['s-button']` with different types conflict. Remove the shim when you opt in. ## Next steps Browse the [component reference](/components/) for the full prop/event list of every wrapper, or read [Known quirks & gotchas](/guide/quirks) before you run into them yourself. Building a Shopify app? See [Build a Shopify embedded app with Vue 3](/guide/shopify-embedded-app) for loading App Bridge, authenticated requests and App Bridge APIs from Vue. Using App Bridge? `polaris-vue-elements/app-bridge` has Vue components for Modal, SaveBar, TitleBar and more: see [App Bridge components](/app-bridge/). They are optional; an app that doesn't import them ships none of their code. Writing CSS of your own around the components? Use the [Polaris CSS variables](/css-variables/) (`--p-space-*`, `--p-color-*`, …) so your layout matches their spacing and colors. --- --- url: https://polaris-vue-elements.dev/guide/shopify-embedded-app.md description: >- Build a Shopify app with Vue 3 and Vite — load App Bridge and Polaris web components, authenticate fetch calls to your backend, and use typed s-* components in App Home. --- # Build a Shopify embedded app with Vue 3 An embedded app (Shopify calls the UI its [App Home](https://shopify.dev/docs/apps/build/app-home)) is a web app you host yourself that Shopify renders in an iframe inside the admin. You can build it with any web framework, including Vue 3. At runtime Shopify gives you two things from its CDN: * **App Bridge** (`app-bridge.js`) connects your iframe to the admin and exposes the global `shopify` object (toasts, modals, navigation, session tokens, ...). * **Polaris web components** (`polaris-2.js`) register the `` custom elements. `polaris-vue-elements` adds typed Vue 3 components (`SPage`, `STextField`, `SModal`, ...) on top of those elements. It is a community project, not made by Shopify. Shopify's own docs and templates target React, so this guide covers the Vue-specific parts. It assumes you have already read [Getting started](/guide/getting-started). ## Architecture * **Frontend:** a Vue 3 + Vite single-page app, served from a URL you control. Shopify loads it in the admin iframe. * **Backend:** any server that can validate Shopify's ID tokens and call the Admin API. Authentication uses [token exchange](https://shopify.dev/docs/apps/build/authentication-authorization/set-embedded-app-authorization): the frontend sends an ID token, your backend validates it and exchanges it for an access token. `shopify app init` scaffolds a React Router app; Shopify does not list a Vue or other non-React template. For another stack, Shopify points you to its authentication docs and the official API library for your language (there is a Node.js one with no framework dependencies). One practical layout is to scaffold the backend however you like, and build the Vue app separately, as described below. In `shopify.app.toml` the app is embedded with `embedded = true` and `application_url` pointing at where your app is served. ## 1. Load App Bridge and Polaris Add the `shopify-api-key` meta tag (your app's client ID) and both scripts to the `` of `index.html`: ```html
``` Vite replaces `%VITE_*%` variables in `index.html` with values from your environment (for example `VITE_SHOPIFY_API_KEY` in `.env`). You can also inject the key from your server instead. App Bridge is not versioned with Polaris: its URL has no version and always loads the latest App Bridge. For the Polaris channels (`polaris-2.js`, pinned releases), see [Known quirks](/guide/quirks#_5-the-polaris-runtime-is-versioned-on-the-cdn-—-this-library-s-version-is-not-the-runtime-s-version). Open the app from the Shopify admin (for example the preview URL printed by `shopify app dev`). Loaded directly in a browser tab, there is no admin around it and App Bridge features will not work. For typed access to the `shopify` global, install Shopify's types package and reference it (Shopify documents `@shopify/app-bridge-types` for this): ```sh npm install -D @shopify/app-bridge-types ``` ```ts // env.d.ts /// ``` The same package types `polaris-vue-elements/app-bridge`, which has Vue components for App Bridge's elements and a `useAppBridge()` composable; see [App Bridge components](/app-bridge/). ## 2. Configure Vite Treat `s-*` tags as custom elements. This is the same config as in [Getting started](/guide/getting-started#_3-configure-vite): ```ts // vite.config.ts import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' export default defineConfig({ plugins: [ vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.startsWith('s-'), }, }, }), ], }) ``` If you write raw App Bridge `ui-*` tags in templates (such as ``), add `|| tag.startsWith('ui-')`. The components in [`polaris-vue-elements/app-bridge`](/app-bridge/#raw-tags) do not need it. ## 3. Build a page This page has a form with `v-model`, a save button that calls your backend, and a modal that confirms a reset. `SModal` is opened declaratively with `commandFor`/`command`; see [`SModal`](/components/s-modal) and the [modal action slot quirk](/guide/quirks#_2-modal-action-slots-only-accept-specific-button-variants). ```vue ``` ## 4. Talk to your backend You usually do not attach a token yourself. App Bridge intercepts `fetch()` and, for requests to your app's domain and subdomains, adds an ID token in the `Authorization` header (and the shop's locale in `Accept-Language`). A plain relative call works: ```ts const response = await fetch('/api/products') const data = await response.json() ``` On the server: * Validate the ID token on every request: HS256 signature with your client secret, `exp` and `nbf`, `aud` equal to your client ID, and matching `iss` and `dest` hostnames. Respond `401` on failure. * ID tokens expire after one minute and are bearer credentials: send them only to your own backend. * Exchange the ID token for an access token to call the Admin API, and keep that token on the server. Call `shopify.idToken()` yourself only when the interceptor does not cover the request, such as a WebSocket connection: ```ts const token = await shopify.idToken() const socket = new WebSocket(`wss://your-app.example.com/ws?token=${token}`) ``` If your app only needs the GraphQL Admin API, App Bridge can route `fetch('shopify:admin/api/graphql.json', ...)` through the admin when Direct API access is enabled in your app configuration, with no backend of your own. See [Resource fetching](https://shopify.dev/docs/api/app-home/apis/authentication-and-data/resource-fetching-api). ## 5. Use App Bridge APIs from Vue Everything is on the `shopify` global; no Vue plugin is needed. `useAppBridge()` from `polaris-vue-elements/app-bridge` returns the same global, and gives a clear error on the server or when the App Bridge script is missing; see [useAppBridge()](/app-bridge/use-app-bridge). ### Toasts ```ts shopify.toast.show('Product saved', { duration: 5000, action: 'Undo', onAction: () => undoSave(), }) ``` `show(message, options)` accepts `duration` (ms), `isError`, `action`, `onAction` and `onDismiss`, and returns an id you can pass to `shopify.toast.hide(id)`. ### Modals by id Besides `commandFor`, `shopify.modal` controls an `SModal` by its `id`: ```ts await shopify.modal.show('reset-modal') await shopify.modal.hide('reset-modal') ``` ### App navigation `` renders the app's navigation in the admin sidebar. Keep it mounted near the root of your app, for example in `App.vue`: ```vue ``` The active item is derived from the current URL. To navigate from code, Shopify's [Navigation API](https://shopify.dev/docs/api/app-home/apis/user-interface-and-interactions/navigation-api) documents anchors, `open('/settings', '_self')` and the History API (`history.pushState`). ### Save bar Add `data-save-bar` to a `
` and the admin shows a save bar when the form has unsaved changes; `submit` fires on Save and `reset` on Discard. Do not combine it with the programmatic `shopify.saveBar` methods on the same form. See [Save bar](https://shopify.dev/docs/api/app-home/apis/user-interface-and-interactions/save-bar-api). For a `ui-save-bar` element bound to `v-model:open`, see [`SaveBar`](/app-bridge/save-bar). ## Next steps * Browse [all components](/components/) and read [Known quirks](/guide/quirks). * Use the [App Bridge components](/app-bridge/) (`Modal`, `SaveBar`, `AppWindow`, ...). * Revisit [Getting started](/guide/getting-started) for `v-model`, overlays and typing raw tags. * Read Shopify's [App Home docs](https://shopify.dev/docs/apps/build/app-home) and [App Bridge APIs](https://shopify.dev/docs/api/app-home/apis). --- --- url: https://polaris-vue-elements.dev/guide/quirks.md description: >- Browser-verified quirks of Shopify Polaris web components when used from Vue 3 — slot requirements, event timing and v-model behaviors that differ from typical Vue component libraries. --- # Known quirks & gotchas These are real, browser-verified behaviors of the underlying Polaris web components that don't always match what you'd expect coming from a typical Vue component library. Reading this before you hit them will save you some debugging time. ## 1. `` needs slot content A `heading` attribute alone is not enough — `` renders empty unless it also has default-slot content. ```vue Something you should know about. ``` ## 2. Modal action slots only accept specific button variants `SModal`'s `primary-action` slot only accepts a single button with `variant="primary"`. Polaris assigns slot content manually under the hood, and any node that doesn't match is **silently dropped** — no warning, no error, it just doesn't render. `secondary-actions` accepts buttons with `variant` `secondary` or `auto`. ```vue ``` ## 3. Number-typed props must be bound, not written as string attributes Polaris's own documentation shows plain HTML attributes (e.g. `rows="3"`), but that's misleading in Vue: for props typed as `number`, `vue-tsc` expects a bound expression, not a string literal. ```vue ``` ## 4. Slot assignment happens once, at connect time Changing a child's `slot` attribute after the parent has mounted does not re-assign it. If you need an element to move between named slots, re-render it (e.g. with `v-if`/`:key`) rather than mutating `slot` reactively. ```vue ... ... ``` ## 5. The Polaris runtime is versioned on the CDN — this library's version is not the runtime's version Since August 2026 the Polaris CDN follows semantic versioning ([changelog](https://shopify.dev/changelog/the-polaris-cdn-is-adopting-semantic-versioning)). Pick the channel that fits your release process: | URL | What it serves | | --- | --- | | `polaris-2.js` | Stable 2.x channel — the new Shopify admin visual style; receives compatible (minor) updates automatically. **Recommended.** | | `polaris-2.0.js` | Pinned release — no feature, fix or visual changes until you move the pin. | | `polaris-1.js` | Previous stable 1.x channel. | | `polaris.js` | Legacy URL — currently serves the same build as `polaris-1.js` and never moves to a new major on its own. | A new major (such as 2.0) is always opt-in: you change the script URL. Polaris 2.0 is a visual update: its Custom Elements Manifest (`@shopify/polaris-types@2.0.0`) declares the same tags, props, events and slots as 1.1 plus a few additions (`SThumbnail`'s `loading` prop, more `STextField` icons), so these wrappers also work against `polaris-1.js`. Whichever channel you load, the runtime updates independently of the version of `polaris-vue-elements` you have installed. This library's version only reflects the freshness of its generated **types and wrappers**: * A stale wrapper never breaks components that already exist — it just may be missing typed props/events for features Shopify added after the wrapper was last generated. * Unknown props still work: they pass through untyped via `$attrs` onto the underlying element. * Unknown/new components still work: use the raw custom element tag directly (e.g. ``) until a typed wrapper is generated for it. ```vue ``` --- --- url: https://polaris-vue-elements.dev/guide/pug.md description: >- Write polaris-vue-elements components in Vue single-file components with