Swish Developer Docs
Go to websiteInstall now
  • Swish API
    • Overview
    • Authentication
    • Rate limits
    • Pagination
    • Errors
    • API Reference
      • Items
      • Lists
      • Profiles
  • Libraries
    • API Client
    • Browser
    • Node.js
    • React
Powered by GitBook
On this page
  • Requirements
  • Swish App Proxy
  • Installation
  • Usage
  • Reference
  1. Libraries

Browser

JS library to integrate Swish into a browser environment.

PreviousAPI ClientNextNode.js

Last updated 2 months ago

JavaScript library for integrating Swish on a Shopify web store (themes and headless stacks).

Requirements

This library depends on the following browser APIs.

Swish App Proxy

The Swish browser library requires a proxy service that operates on the same domain as the store. This service facilitates the loading of additional resources and ensures secure communication with the Swish API. The app proxy is automatically provided once the app has been installed.

If your store has it's own server (e.g. headless stack), then you will need to implement the proxy first. Please use the to implement the app proxy.

Installation

To load the Swish app, you can either activate the Swish embed through your theme editor or install it via NPM. We recommend using the app embed for most scenarios. For headless stacks, NPM is necessary.

Usage

import { swishApp } from "/apps/wishlist/assets/swish.js";

const swish = await swishApp({
  proxy: {
    baseUrl: "/apps/wishlist"
  }
});

const { data } = await swish.api.items.list();

Reference

Swish API

All Swish API functions can be accessed and are automatically scoped to the current user.

const { data } = await swish.api.items.list();

Swish UI Components

This feature is still under development!

To accelerate development, consider using our built-in UI components. These components follow a general design language and allow for some customisation. For a completely tailored user experience, creating your own UI components is recommended.

Our components load only when needed, enabling you to blend custom UI elements with our standard components without impacting your page speed.

await swish.ui.showSignIn({
  returnTo: window.location.pathname
});

Please refer to the docs for a comprehensive list of available functions.

Fetch API
Service Worker API
Web Workers API
Node.js library
Swish API Client