@swishapp/react for the UI layer and @swishapp/auth-proxy for secure token creation on the server.
Before you start, make sure you have:
- Swish installed from the Shopify App Store
- A Hydrogen project running locally
- A Swish API token (contact support@swish.app to request one)
- A Shopify Storefront API access token (see configuration reference for how to create one)
Install packages
Set up the auth proxy
Create a server route that securely creates Swish API tokens. The auth proxy validates the request and forwards it to the Swish API using your secret token.app/routes/api.swish-token.ts
authenticate callback returns the Shopify customer ID for logged-in customers, or null for guests. See the auth proxy reference for all configuration options.
Add SwishProvider
Wrap your app inSwishProvider so all child components can use Swish hooks. A good place is a layout route that has access to customer and localization data from your Hydrogen loader.
app/components/SwishSetup.tsx
app/root.tsx
The SDK is client-only.
SwishProvider renders safely during SSR, but the SDK initializes after hydration. Hooks return loading states until then.options shape.
Add a save button
UseuseSwishItem on a product detail page to let customers save and unsave products.
app/components/SaveButton.tsx
Add an item count badge
UseuseSwishItemCount to show how many items a customer has saved, for example in the site header.
app/components/SwishBadge.tsx
Sample
A more complete example showing a product detail page with a save button and the item count badge in the header.app/routes/products.$handle.tsx
app/components/Header.tsx
swish-intent="view:home" attribute opens the Swish drawer when clicked, no JavaScript handler needed. See the intents reference for all available intents.
Next steps
Customization
Design tokens, translations, and component configuration.
Intents
Trigger actions like save, unsave, open drawer, and quick buy.
React hooks
All available hooks for items, lists, counts, and queries.