Skip to main content
Intents are the primary way to trigger Swish actions from your storefront. Each intent represents a specific action - saving a product, opening a list, starting a checkout - and the SDK handles the UI and workflow automatically.

Invoking intents

From JavaScript

Use swish.intents.invoke() to trigger an intent programmatically. It returns a promise that resolves to an activity handle with a complete property you can await for the result.

From HTML attributes

Add the swish-intent attribute to any clickable element. The SDK automatically attaches a click handler. Parameters use search-param style syntax after the intent name.
For drawer triggers with a live saved-item count, use <swish-drawer> instead of swish-intent - it wraps the same open-view intent and binds the count for you:

From URL query strings

Trigger intents via URL parameters. This is useful for deep links in emails or external campaigns. Intent parameters are passed as standard URL query params alongside swish-intent.

From Shopify product URLs

On product detail pages, the SDK automatically reads the product handle from the URL path and the variant from the query string. You can turn any product URL into a save link by adding &swish-intent=save:item.
This also works with anchor links inside your store:

From URL hash

A subset of navigation intents can be triggered via URL hash:

String parameter names

When invoking intents from HTML attributes or URLs, use these short parameter names: The product parameter accepts a numeric ID, a Shopify GID, or a product handle (e.g. meadow-dress). When a handle is provided, the SDK resolves it to a product ID via the Storefront API.
The long-form names (productId, variantId, etc.) also work in strings and URLs as a fallback, but the short names are recommended.

Response format

Every intent resolves with a response containing a code field:

Listening for intent completions

Use swish.intents.listen() to subscribe to intent completions without invoking them yourself. This is useful for reacting to intents triggered by the Swish UI or declarative triggers.

Cross-intent resolution

Some intents can resolve as a different intent depending on what the customer does. For example, unsave:item can resolve as edit:item-lists when the customer moves an item to another list instead of removing it. When this happens and the intent succeeds, the SDK fires listeners for both the originally invoked intent and the resolved intent. This means your listener catches the action regardless of which intent triggered it.
Intents that can resolve as a different intent:

Intent reference

Items

save:item

Save a product to the customer’s list.

unsave:item

Remove a saved item.

edit:item-variant

Change the selected variant on a saved item.

edit:item-quantity

Change the quantity stored on a saved item. The product detail view in the drawer invokes it when the customer changes the quantity input on a saved item.

edit:item-lists

Move or copy a saved item between lists.

Lists

create:list

Open the create list dialog. No parameters.

edit:list

Open the edit dialog for an existing list.

edit:list-access

Change a list’s visibility.

delete:list

Delete a list.

initiate:share

Open the share dialog for a list.

Cart

create:cart-line

Add one or more items to the cart.

initiate:checkout

Start a checkout with one or more items. Accepts the same parameters as create:cart-line.

save:cart-line

Save removed cart items to the customer’s list. Typically triggered automatically when the removeCartLine.saveCartLine option is enabled.

view:home

Open Swish on the view ui.defaultView names, which is the Home view unless you change it. No parameters.

view:saves

Open the saved items view. No parameters.

view:lists

Open the lists view. No parameters.

view:list

Open a specific list.

view:orders

Open the orders view. No parameters.

view:order

Open a specific order.

view:notifications

Open the notifications view. No parameters.

view:profile

Open the customer profile. No parameters.

view:product

Open the product detail view.

view:list-menu

Open the context menu for a list.

view:order-menu

Open the context menu for an order.

view:list-detail-page-menu

Open the context menu on a list detail page.

view:account-menu

Open the account menu behind the List detail page’s account button: the customer’s lists, their account page and sign out. Takes no parameters. The lists row is only offered where the drawer is on, and the account row is a plain link to the store’s account URL.

Auth

initiate:sign-in

Start the sign-in flow with a redirect.

initiate:sign-out

Sign the customer out and redirect to the store root. No parameters.

UI

initiate:quick-buy

Open the quick buy dialog for a product, or add a known variant straight to the cart. With a variantId, there is nothing left to pick, so the variant goes straight to the cart and the intent resolves as create:cart-line. Without one, the dialog opens for the customer to pick a variant. Set promptVariantIfPresent to true to open the dialog on a known variant too.

create:subscription

Open the Notify Me dialog so a shopper can ask to hear when a sold-out variant is back in stock. Submitting it creates a back-in-stock subscription. Subscriptions are variant-level, but variantId is optional: omit it and the dialog shows a variant picker and resolves the variant before it subscribes. Pass it and the dialog opens straight on that variant with only the email left to fill in.
On a product that is sold out in every size with nothing picked yet, leave variantId off. The dialog opens on an empty picker and the subscription it returns is for the variant the shopper settled on there.
A signed-in shopper’s email is pre-filled from context.customer.email; a guest types one and subscribes on a session token. Submitting confirms in place and the dialog stays there until the shopper dismisses it, so activity.complete resolves when they close the confirmation rather than the moment they submit. A shopper who subscribes and then closes still comes back as ok with their subscription; one who closes without subscribing comes back as closed.

show:toast

Display a toast notification.