@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 Next.js project running locally (App Router)
- 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 Route Handler that securely creates Swish API tokens. The auth proxy validates the request and forwards it to the Swish API using your secret token.app/api/swish-token/route.ts
authenticate callback returns the Shopify customer ID for logged-in customers, or null for guests. Replace getSession with your own session logic. See the auth proxy reference for all configuration options.
Add SwishProvider
SwishProvider is a client component. Create a wrapper that accepts customer and localization data as props from a server component.
components/swish-setup.tsx
customer.tags is optional. Pass it to target content blocks at tagged customers; omit it and those blocks simply never match.
Then use it in your root layout. The layout is a server component, so you can fetch customer and localization data before passing them down.
app/layout.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. Hooks require a client component.
components/save-button.tsx
Add an item count badge
UseuseSwishItemCount to show how many items a customer has saved, for example in the site header.
components/swish-badge.tsx
Sample
A more complete example showing a product detail page with a save button and the item count badge in the header.app/products/[handle]/page.tsx
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.